Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 161932 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/ChangeCapabilityNameCommandTest.java (-77 / +77 lines)
Lines 31-112 Link Here
31
 */
31
 */
32
public class ChangeCapabilityNameCommandTest extends OverviewCommandTestModel
32
public class ChangeCapabilityNameCommandTest extends OverviewCommandTestModel
33
{
33
{
34
    /**
34
	/**
35
         * Constructor for ChangeCapabilityNameCommandTest.
35
	 * Constructor for ChangeCapabilityNameCommandTest.
36
         * 
36
	 * 
37
         * @param name
37
	 * @param name
38
         */
38
	 */
39
    public ChangeCapabilityNameCommandTest(String name)
39
	public ChangeCapabilityNameCommandTest(String name)
40
    {
40
	{
41
	super(name);
41
		super(name);
42
    }
42
	}
43
43
44
    /**
44
	/**
45
         * Returns the JUnit test suite that implements the
45
	 * Returns the JUnit test suite that implements the
46
         * <b>ChangeCapabilityNameCommandTest</b> definition.
46
	 * <b>ChangeCapabilityNameCommandTest</b> definition.
47
         */
47
	 */
48
    public static Test suite()
48
	public static Test suite()
49
    {
49
	{
50
	HyadesTestSuite changeCapabilityNameCommandTest = new HyadesTestSuite(
50
		HyadesTestSuite changeCapabilityNameCommandTest = new HyadesTestSuite(
51
		"ChangeCapabilityNameCommandTest");
51
				"ChangeCapabilityNameCommandTest");
52
	changeCapabilityNameCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
52
		changeCapabilityNameCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
53
		.setId("C8E89291F2E4762C20D74B700FFB11DB");
53
				.setId("C8E89291F2E4762C20D74B700FFB11DB");
54
54
55
	changeCapabilityNameCommandTest
55
		changeCapabilityNameCommandTest
56
		.addTest(new ChangeCapabilityNameCommandTest(
56
				.addTest(new ChangeCapabilityNameCommandTest(
57
			"testChangeCapabilityName"));
57
						"testChangeCapabilityName"));
58
58
59
	return changeCapabilityNameCommandTest;
59
		return changeCapabilityNameCommandTest;
60
    }
60
	}
61
61
62
    /**
62
	/**
63
         * @see junit.framework.TestCase#setUp()
63
	 * @see junit.framework.TestCase#setUp()
64
         */
64
	 */
65
    protected void setUp() throws Exception
65
	protected void setUp() throws Exception
66
    {
66
	{
67
	super.setUp();
67
		super.setUp();
68
    }
68
	}
69
69
70
    /**
70
	/**
71
         * @see junit.framework.TestCase#tearDown()
71
	 * @see junit.framework.TestCase#tearDown()
72
         */
72
	 */
73
    protected void tearDown() throws Exception
73
	protected void tearDown() throws Exception
74
    {
74
	{
75
    }
75
	}
76
76
77
    /**
77
	/**
78
         * testChangeCapabilityName
78
	 * testChangeCapabilityName
79
         * 
79
	 * 
80
         * @throws Exception
80
	 * @throws Exception
81
         */
81
	 */
82
    public void testChangeCapabilityName() throws Exception
82
	public void testChangeCapabilityName() throws Exception
83
    {
83
	{
84
	String newName = "MyAppServer";
84
		String newName = "MyAppServer";
85
	ChangeCapabilityNameCommand command = new ChangeCapabilityNameCommand(
85
		ChangeCapabilityNameCommand command = new ChangeCapabilityNameCommand(
86
		capabilityDomain, newName);
86
				capabilityDomain, newName);
87
	command.execute();
87
		command.execute();
88
88
89
	assertEquals(newName, capability.getName());
89
		assertEquals(newName, capability.getName());
90
	assertEquals(newName, definition.getQName().getLocalPart());
90
		assertEquals(newName, definition.getQName().getLocalPart());
91
91
92
	PortType pt = WsdlUtils.getPortType(definition);
92
		PortType pt = WsdlUtils.getPortType(definition);
93
	assertEquals(newName + "PortType", pt.getQName().getLocalPart());
93
		assertEquals(newName + "PortType", pt.getQName().getLocalPart());
94
94
95
	String metaDataDescriptorName = newName + "Descriptor";
95
		String metaDataDescriptorName = newName + "Descriptor";
96
	MetadataDescriptorType metaDescriptorType = metaDataDescriptor
96
		MetadataDescriptorType metaDescriptorType = metaDataDescriptor
97
		.getMetadataDescriptorType();
97
				.getMetadataDescriptorType();
98
	assertEquals(metaDataDescriptorName, metaDescriptorType.getName());
98
		assertEquals(metaDataDescriptorName, metaDescriptorType.getName());
99
	Attr descriptorAttribute = pt.getElement().getAttributeNodeNS(
99
		Attr descriptorAttribute = pt.getElement().getAttributeNodeNS(
100
		WsdmConstants.WSRMD_NS, WsdlUtils.METADATA_DESCRIPTOR_KEY);
100
				WsdmConstants.WSRMD_NS, WsdlUtils.METADATA_DESCRIPTOR_KEY);
101
	assertTrue(descriptorAttribute.getNodeValue().indexOf(
101
		assertTrue(descriptorAttribute.getNodeValue().indexOf(
102
		metaDataDescriptorName) != -1);
102
				metaDataDescriptorName) != -1);
103
103
104
	String rpElementName = newName + "Properties";
104
		String rpElementName = newName + "Properties";
105
	assertEquals(rpElementName, resourcePropertyElement.getName());
105
		assertEquals(rpElementName, resourcePropertyElement.getName());
106
	Attr rpElementAttribute = pt.getElement().getAttributeNodeNS(
106
		Attr rpElementAttribute = pt.getElement().getAttributeNodeNS(
107
		WsdmConstants.WSRP_NS,
107
				WsdmConstants.WSRP_NS,
108
		WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY);
108
				WsdlUtils.RESOURCE_PROPERTIES_ELEMENT_KEY);
109
	assertTrue(rpElementAttribute.getNodeValue().indexOf(rpElementName) != -1);
109
		assertTrue(rpElementAttribute.getNodeValue().indexOf(rpElementName) != -1);
110
    }
110
	}
111
111
112
}
112
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/ChangeCapabilityNamespaceCommandTest.java (-123 / +123 lines)
Lines 31-160 Link Here
31
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/overview/command/ChangeCapabilityNamespaceCommandTest.testsuite</i>.
31
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/overview/command/ChangeCapabilityNamespaceCommandTest.testsuite</i>.
32
 */
32
 */
33
public class ChangeCapabilityNamespaceCommandTest extends
33
public class ChangeCapabilityNamespaceCommandTest extends
34
	OverviewCommandTestModel
34
		OverviewCommandTestModel
35
{
35
{
36
    /**
36
	/**
37
         * Constructor for ChangeCapabilityNamespaceCommandTest.
37
	 * Constructor for ChangeCapabilityNamespaceCommandTest.
38
         * 
38
	 * 
39
         * @param name
39
	 * @param name
40
         */
40
	 */
41
41
42
    private String oldNamespace;
42
	private String oldNamespace;
43
43
44
    public ChangeCapabilityNamespaceCommandTest(String name)
44
	public ChangeCapabilityNamespaceCommandTest(String name)
45
    {
45
	{
46
	super(name);
46
		super(name);
47
    }
47
	}
48
48
49
    /**
49
	/**
50
         * Returns the JUnit test suite that implements the
50
	 * Returns the JUnit test suite that implements the
51
         * <b>ChangeCapabilityNamespaceCommandTest</b> definition.
51
	 * <b>ChangeCapabilityNamespaceCommandTest</b> definition.
52
         */
52
	 */
53
    public static Test suite()
53
	public static Test suite()
54
    {
54
	{
55
	HyadesTestSuite changeCapabilityNamespaceCommandTest = new HyadesTestSuite(
55
		HyadesTestSuite changeCapabilityNamespaceCommandTest = new HyadesTestSuite(
56
		"ChangeCapabilityNamespaceCommandTest");
56
				"ChangeCapabilityNamespaceCommandTest");
57
	changeCapabilityNamespaceCommandTest.setArbiter(
57
		changeCapabilityNamespaceCommandTest.setArbiter(
58
		DefaultTestArbiter.INSTANCE).setId(
58
				DefaultTestArbiter.INSTANCE).setId(
59
		"C8E89291F2E4762C1F54D4B00FFC11DB");
59
				"C8E89291F2E4762C1F54D4B00FFC11DB");
60
60
61
	changeCapabilityNamespaceCommandTest
61
		changeCapabilityNamespaceCommandTest
62
		.addTest(new ChangeCapabilityNamespaceCommandTest(
62
				.addTest(new ChangeCapabilityNamespaceCommandTest(
63
			"testChangeCapabilityNamespace"));
63
						"testChangeCapabilityNamespace"));
64
64
65
	return changeCapabilityNamespaceCommandTest;
65
		return changeCapabilityNamespaceCommandTest;
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * @see junit.framework.TestCase#setUp()
69
	 * @see junit.framework.TestCase#setUp()
70
         */
70
	 */
71
    protected void setUp() throws Exception
71
	protected void setUp() throws Exception
72
    {
72
	{
73
	super.setUp();
73
		super.setUp();
74
    }
74
	}
75
75
76
    /**
76
	/**
77
         * @see junit.framework.TestCase#tearDown()
77
	 * @see junit.framework.TestCase#tearDown()
78
         */
78
	 */
79
    protected void tearDown() throws Exception
79
	protected void tearDown() throws Exception
80
    {
80
	{
81
    }
81
	}
82
82
83
    /**
83
	/**
84
         * testChangeCapabilityNamespace
84
	 * testChangeCapabilityNamespace
85
         * 
85
	 * 
86
         * @throws Exception
86
	 * @throws Exception
87
         */
87
	 */
88
    public void testChangeCapabilityNamespace() throws Exception
88
	public void testChangeCapabilityNamespace() throws Exception
89
    {
89
	{
90
	oldNamespace = new String(definition.getTargetNamespace());
90
		oldNamespace = new String(definition.getTargetNamespace());
91
	String newNamespace = "http://w3.ibm.com/appserver";
91
		String newNamespace = "http://w3.ibm.com/appserver";
92
	ChangeCapabilityNamespaceCommand command = new ChangeCapabilityNamespaceCommand(
92
		ChangeCapabilityNamespaceCommand command = new ChangeCapabilityNamespaceCommand(
93
		capabilityDomain, newNamespace);
93
				capabilityDomain, newNamespace);
94
	command.execute();
94
		command.execute();
95
95
96
	assertEquals(newNamespace, capability.getNamespace());
96
		assertEquals(newNamespace, capability.getNamespace());
97
	assertEquals(newNamespace, definition.getTargetNamespace());
97
		assertEquals(newNamespace, definition.getTargetNamespace());
98
	assertEquals(newNamespace, propSchema.getTargetNamespace());
98
		assertEquals(newNamespace, propSchema.getTargetNamespace());
99
99
100
	checkInsideWSDL();
100
		checkInsideWSDL();
101
	checkInsideWSDLSchemas();
101
		checkInsideWSDLSchemas();
102
	checkInsidePropertiesSchema();
102
		checkInsidePropertiesSchema();
103
	checkInsideRMD();
103
		checkInsideRMD();
104
    }
104
	}
105
105
106
    private void checkInsideWSDL()
106
	private void checkInsideWSDL()
107
    {
107
	{
108
	String prefix = WsdlUtils.getPrefix(definition, oldNamespace);
108
		String prefix = WsdlUtils.getPrefix(definition, oldNamespace);
109
	assertNull(prefix);
109
		assertNull(prefix);
110
    }
110
	}
111
111
112
    private void checkInsideWSDLSchemas()
112
	private void checkInsideWSDLSchemas()
113
    {
113
	{
114
	XSDSchema[] schemas = WsdlUtils.getXSDSchemas(definition);
114
		XSDSchema[] schemas = WsdlUtils.getXSDSchemas(definition);
115
	assertNotNull(schemas);
115
		assertNotNull(schemas);
116
	assertTrue(schemas.length > 0);
116
		assertTrue(schemas.length > 0);
117
117
118
	for (int i = 0; i < schemas.length; i++)
118
		for (int i = 0; i < schemas.length; i++)
119
	{
119
		{
120
	    checkInSchema(schemas[i]);
120
			checkInSchema(schemas[i]);
121
	}
121
		}
122
    }
122
	}
123
123
124
    private void checkInsidePropertiesSchema()
124
	private void checkInsidePropertiesSchema()
125
    {
125
	{
126
	checkInSchema(propSchema);
126
		checkInSchema(propSchema);
127
    }
127
	}
128
128
129
    private void checkInSchema(XSDSchema schema)
129
	private void checkInSchema(XSDSchema schema)
130
    {
130
	{
131
	Map nsMap = schema.getQNamePrefixToNamespaceMap();
131
		Map nsMap = schema.getQNamePrefixToNamespaceMap();
132
	Iterator valueIt = nsMap.values().iterator();
132
		Iterator valueIt = nsMap.values().iterator();
133
	while (valueIt.hasNext())
133
		while (valueIt.hasNext())
134
	{
134
		{
135
	    String value = (String) valueIt.next();
135
			String value = (String) valueIt.next();
136
	    if (value.equals(oldNamespace))
136
			if (value.equals(oldNamespace))
137
		throw new AssertionFailedError(
137
				throw new AssertionFailedError(
138
			"Not able to change the namespace in schema -- "
138
						"Not able to change the namespace in schema -- "
139
				+ schema.getTargetNamespace());
139
								+ schema.getTargetNamespace());
140
	}
140
		}
141
    }
141
	}
142
142
143
    private void checkInsideRMD()
143
	private void checkInsideRMD()
144
    {
144
	{
145
	EMap map = metaDataDescriptor.getDocumentRoot().getXMLNSPrefixMap();
145
		EMap map = metaDataDescriptor.getDocumentRoot().getXMLNSPrefixMap();
146
	Iterator mapIt = map.iterator();
146
		Iterator mapIt = map.iterator();
147
	while (mapIt.hasNext())
147
		while (mapIt.hasNext())
148
	{
148
		{
149
	    Object object = mapIt.next();
149
			Object object = mapIt.next();
150
	    if (object instanceof EStringToStringMapEntryImpl)
150
			if (object instanceof EStringToStringMapEntryImpl)
151
	    {
151
			{
152
		EStringToStringMapEntryImpl entry = (EStringToStringMapEntryImpl) object;
152
				EStringToStringMapEntryImpl entry = (EStringToStringMapEntryImpl) object;
153
		if (entry.getValue().equals(oldNamespace))
153
				if (entry.getValue().equals(oldNamespace))
154
		    throw new AssertionFailedError(
154
					throw new AssertionFailedError(
155
			    "Not able to change the namespace in rmd");
155
							"Not able to change the namespace in rmd");
156
	    }
156
			}
157
		}
157
	}
158
	}
158
    }
159
159
160
}
160
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/AllOverviewCommandTest.java (-51 / +51 lines)
Lines 24-79 Link Here
24
 */
24
 */
25
public class AllOverviewCommandTest extends HyadesTestCase
25
public class AllOverviewCommandTest extends HyadesTestCase
26
{
26
{
27
    /**
27
	/**
28
         * Constructor for AllOverviewCommandTest.
28
	 * Constructor for AllOverviewCommandTest.
29
         * 
29
	 * 
30
         * @param name
30
	 * @param name
31
         */
31
	 */
32
    public AllOverviewCommandTest(String name)
32
	public AllOverviewCommandTest(String name)
33
    {
33
	{
34
	super(name);
34
		super(name);
35
    }
35
	}
36
36
37
    /**
37
	/**
38
         * Returns the JUnit test suite that implements the
38
	 * Returns the JUnit test suite that implements the
39
         * <b>AllOverviewCommandTest</b> definition.
39
	 * <b>AllOverviewCommandTest</b> definition.
40
         */
40
	 */
41
    public static Test suite()
41
	public static Test suite()
42
    {
42
	{
43
	HyadesTestSuite allOverviewCommandTest = new HyadesTestSuite(
43
		HyadesTestSuite allOverviewCommandTest = new HyadesTestSuite(
44
		"AllOverviewCommandTest");
44
				"AllOverviewCommandTest");
45
	allOverviewCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
45
		allOverviewCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
46
		"C8E89291F2E4762C045BB3700FFE11DB");
46
				"C8E89291F2E4762C045BB3700FFE11DB");
47
47
48
	allOverviewCommandTest.addTest(HyadesJUnitRunner
48
		allOverviewCommandTest.addTest(HyadesJUnitRunner
49
		.getTest(ChangeCapabilityNameCommandTest.class));
49
				.getTest(ChangeCapabilityNameCommandTest.class));
50
50
51
	allOverviewCommandTest.addTest(HyadesJUnitRunner
51
		allOverviewCommandTest.addTest(HyadesJUnitRunner
52
		.getTest(ChangeCapabilityNamespaceCommandTest.class));
52
				.getTest(ChangeCapabilityNamespaceCommandTest.class));
53
53
54
	allOverviewCommandTest.addTest(HyadesJUnitRunner
54
		allOverviewCommandTest.addTest(HyadesJUnitRunner
55
		.getTest(ChangeCapabilityDescriptionCommandTest_1.class));
55
				.getTest(ChangeCapabilityDescriptionCommandTest_1.class));
56
56
57
	allOverviewCommandTest.addTest(HyadesJUnitRunner
57
		allOverviewCommandTest.addTest(HyadesJUnitRunner
58
		.getTest(ChangeCapabilityDescriptionCommandTest_2.class));
58
				.getTest(ChangeCapabilityDescriptionCommandTest_2.class));
59
59
60
	allOverviewCommandTest.addTest(HyadesJUnitRunner
60
		allOverviewCommandTest.addTest(HyadesJUnitRunner
61
		.getTest(ChangeCapabilityDescriptionCommandTest_3.class));
61
				.getTest(ChangeCapabilityDescriptionCommandTest_3.class));
62
	return allOverviewCommandTest;
62
		return allOverviewCommandTest;
63
    }
63
	}
64
64
65
    /**
65
	/**
66
         * @see junit.framework.TestCase#setUp()
66
	 * @see junit.framework.TestCase#setUp()
67
         */
67
	 */
68
    protected void setUp() throws Exception
68
	protected void setUp() throws Exception
69
    {
69
	{
70
    }
70
	}
71
71
72
    /**
72
	/**
73
         * @see junit.framework.TestCase#tearDown()
73
	 * @see junit.framework.TestCase#tearDown()
74
         */
74
	 */
75
    protected void tearDown() throws Exception
75
	protected void tearDown() throws Exception
76
    {
76
	{
77
    }
77
	}
78
78
79
}
79
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/OverviewCommandTestModel.java (-9 / +9 lines)
Lines 17-30 Link Here
17
17
18
public class OverviewCommandTestModel extends CapabilityTestModel
18
public class OverviewCommandTestModel extends CapabilityTestModel
19
{
19
{
20
    public OverviewCommandTestModel(String name)
20
	public OverviewCommandTestModel(String name)
21
    {
21
	{
22
	this(name, Activator.PLUGIN_ID + "/"
22
		this(name, Activator.PLUGIN_ID + "/"
23
		+ "testfiles/capability/command/overview/MyDescription_1.mcap");
23
				+ "testfiles/capability/command/overview/MyDescription_1.mcap");
24
    }
24
	}
25
25
26
    public OverviewCommandTestModel(String name, String CapabilityIFilePath)
26
	public OverviewCommandTestModel(String name, String CapabilityIFilePath)
27
    {
27
	{
28
	super(name, CapabilityIFilePath);
28
		super(name, CapabilityIFilePath);
29
    }
29
	}
30
}
30
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/ChangeCapabilityDescriptionCommandTest_3.java (-90 / +91 lines)
Lines 21-26 Link Here
21
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.overview.internal.ChangeCapabilityDescriptionCommand;
21
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.overview.internal.ChangeCapabilityDescriptionCommand;
22
import org.eclipse.tptp.wsdm.tooling.editor.capability.test.Activator;
22
import org.eclipse.tptp.wsdm.tooling.editor.capability.test.Activator;
23
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
23
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
24
import org.eclipse.wst.wsdl.Definition;
24
import org.eclipse.xsd.XSDAnnotation;
25
import org.eclipse.xsd.XSDAnnotation;
25
import org.eclipse.xsd.XSDSchema;
26
import org.eclipse.xsd.XSDSchema;
26
27
Lines 30-125 Link Here
30
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/overview/command/ChangeCapabilityDescriptionCommandTest_3.testsuite</i>.
31
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/overview/command/ChangeCapabilityDescriptionCommandTest_3.testsuite</i>.
31
 */
32
 */
32
public class ChangeCapabilityDescriptionCommandTest_3 extends
33
public class ChangeCapabilityDescriptionCommandTest_3 extends
33
	OverviewCommandTestModel
34
		OverviewCommandTestModel
34
{
35
{
35
    /**
36
	/**
36
         * Constructor for ChangeCapabilityDescriptionCommandTest_3.
37
	 * Constructor for ChangeCapabilityDescriptionCommandTest_3.
37
         * 
38
	 * 
38
         * @param name
39
	 * @param name
39
         */
40
	 */
40
    public ChangeCapabilityDescriptionCommandTest_3(String name)
41
	public ChangeCapabilityDescriptionCommandTest_3(String name)
41
    {
42
	{
42
	super(name, Activator.PLUGIN_ID + "/"
43
		super(name, Activator.PLUGIN_ID + "/"
43
		+ "testfiles/capability/command/overview/MyDescription_3.mcap");
44
				+ "testfiles/capability/command/overview/MyDescription_3.mcap");
44
    }
45
	}
45
46
46
    /**
47
	/**
47
         * Returns the JUnit test suite that implements the
48
	 * Returns the JUnit test suite that implements the
48
         * <b>ChangeCapabilityDescriptionCommandTest_3</b> definition.
49
	 * <b>ChangeCapabilityDescriptionCommandTest_3</b> definition.
49
         */
50
	 */
50
    public static Test suite()
51
	public static Test suite()
51
    {
52
	{
52
	HyadesTestSuite changeCapabilityDescriptionCommandTest_3 = new HyadesTestSuite(
53
		HyadesTestSuite changeCapabilityDescriptionCommandTest_3 = new HyadesTestSuite(
53
		"ChangeCapabilityDescriptionCommandTest_3");
54
				"ChangeCapabilityDescriptionCommandTest_3");
54
	changeCapabilityDescriptionCommandTest_3.setArbiter(
55
		changeCapabilityDescriptionCommandTest_3.setArbiter(
55
		DefaultTestArbiter.INSTANCE).setId(
56
				DefaultTestArbiter.INSTANCE).setId(
56
		"C448865E2C0E25D8ED46319043DF11DB");
57
				"C448865E2C0E25D8ED46319043DF11DB");
57
58
58
	changeCapabilityDescriptionCommandTest_3
59
		changeCapabilityDescriptionCommandTest_3
59
		.addTest(new ChangeCapabilityDescriptionCommandTest_3(
60
				.addTest(new ChangeCapabilityDescriptionCommandTest_3(
60
			"testChangeCapabilityDescription"));
61
						"testChangeCapabilityDescription"));
61
62
62
	return changeCapabilityDescriptionCommandTest_3;
63
		return changeCapabilityDescriptionCommandTest_3;
63
    }
64
	}
64
65
65
    /**
66
	/**
66
         * @see junit.framework.TestCase#setUp()
67
	 * @see junit.framework.TestCase#setUp()
67
         */
68
	 */
68
    protected void setUp() throws Exception
69
	protected void setUp() throws Exception
69
    {
70
	{
70
	super.setUp();
71
		super.setUp();
71
    }
72
	}
72
73
73
    /**
74
	/**
74
         * @see junit.framework.TestCase#tearDown()
75
	 * @see junit.framework.TestCase#tearDown()
75
         */
76
	 */
76
    protected void tearDown() throws Exception
77
	protected void tearDown() throws Exception
77
    {
78
	{
78
    }
79
	}
79
80
80
    /**
81
	/**
81
         * When XSD annotations exists but its an empty element. This should
82
	 * When XSD annotations exists but its an empty element. This should create
82
         * create new description node inside it
83
	 * new description node inside it
83
         * 
84
	 * 
84
         * @throws Exception
85
	 * @throws Exception
85
         */
86
	 */
86
    public void testChangeCapabilityDescription() throws Exception
87
	public void testChangeCapabilityDescription() throws Exception
87
    {
88
	{
88
	String newDescription = "TOMCAT capability";
89
		String newDescription = "TOMCAT capability";
89
90
90
	// There should be one XSD annotation in WSDL schema and it should be
91
		// There should be one XSD annotation in WSDL schema and it should be
91
        // empty element
92
		// empty element
92
	XSDSchema tnsSchema = WsdlUtils.createOrFindSchema(capabilityDomain
93
		Definition definition = capabilityDomain.getCapability()
93
		.getDefinition(), capabilityDomain.getDefinition()
94
				.getDefinition();
94
		.getTargetNamespace());
95
		XSDSchema tnsSchema = WsdlUtils.createOrFindSchema(definition,
95
	List annotations = tnsSchema.getAnnotations();
96
				definition.getTargetNamespace());
96
	assertNotNull(annotations);
97
		List annotations = tnsSchema.getAnnotations();
97
	assertEquals(1, annotations.size());
98
		assertNotNull(annotations);
98
	XSDAnnotation annotation = (XSDAnnotation) annotations.get(0);
99
		assertEquals(1, annotations.size());
99
	assertFalse(annotation.getElement().hasChildNodes());
100
		XSDAnnotation annotation = (XSDAnnotation) annotations.get(0);
100
101
		assertFalse(annotation.getElement().hasChildNodes());
101
	// Change the description
102
102
	ChangeCapabilityDescriptionCommand command = new ChangeCapabilityDescriptionCommand(
103
		// Change the description
103
		capabilityDomain, newDescription);
104
		ChangeCapabilityDescriptionCommand command = new ChangeCapabilityDescriptionCommand(
104
	command.execute();
105
				capabilityDomain, newDescription);
105
106
		command.execute();
106
	// Verify the changes
107
107
	assertNotNull(capabilityDomain.getDescriptionNode());
108
		// Verify the changes
108
	assertEquals(newDescription, capabilityDomain.getDescriptionNode()
109
		assertNotNull(capabilityDomain.getDescriptionNode());
109
		.getData());
110
		assertEquals(newDescription, capabilityDomain.getDescriptionNode()
110
	assertEquals(newDescription, capabilityDomain.getCapability()
111
				.getData());
111
		.getDescription());
112
		assertEquals(newDescription, capabilityDomain.getCapability()
112
113
				.getDescription());
113
	// Verify that it has created new element in XSD annotation
114
114
	XSDSchema schema = WsdlUtils.getSchema(
115
		// Verify that it has created new element in XSD annotation
115
		capabilityDomain.getDefinition(), capabilityDomain
116
		XSDSchema schema = WsdlUtils.getSchema(definition, definition
116
			.getDefinition().getTargetNamespace());
117
				.getTargetNamespace());
117
	List newAnnotations = schema.getAnnotations();
118
		List newAnnotations = schema.getAnnotations();
118
	assertNotNull(newAnnotations);
119
		assertNotNull(newAnnotations);
119
	assertEquals(1, newAnnotations.size());
120
		assertEquals(1, newAnnotations.size());
120
121
121
	annotation = (XSDAnnotation) annotations.get(0);
122
		annotation = (XSDAnnotation) annotations.get(0);
122
	assertTrue(annotation.getElement().hasChildNodes());
123
		assertTrue(annotation.getElement().hasChildNodes());
123
    }
124
	}
124
125
125
}
126
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/ChangeCapabilityDescriptionCommandTest_1.java (-67 / +67 lines)
Lines 25-97 Link Here
25
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/overview/command/ChangeCapabilityDescriptionCommandTest_1.testsuite</i>.
25
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/overview/command/ChangeCapabilityDescriptionCommandTest_1.testsuite</i>.
26
 */
26
 */
27
public class ChangeCapabilityDescriptionCommandTest_1 extends
27
public class ChangeCapabilityDescriptionCommandTest_1 extends
28
	OverviewCommandTestModel
28
		OverviewCommandTestModel
29
{
29
{
30
    /**
30
	/**
31
         * Constructor for ChangeCapabilityDescriptionCommandTest_1.
31
	 * Constructor for ChangeCapabilityDescriptionCommandTest_1.
32
         * 
32
	 * 
33
         * @param name
33
	 * @param name
34
         */
34
	 */
35
    public ChangeCapabilityDescriptionCommandTest_1(String name)
35
	public ChangeCapabilityDescriptionCommandTest_1(String name)
36
    {
36
	{
37
	super(name, Activator.PLUGIN_ID + "/"
37
		super(name, Activator.PLUGIN_ID + "/"
38
		+ "testfiles/capability/command/overview/MyDescription_1.mcap");
38
				+ "testfiles/capability/command/overview/MyDescription_1.mcap");
39
    }
39
	}
40
40
41
    /**
41
	/**
42
         * Returns the JUnit test suite that implements the
42
	 * Returns the JUnit test suite that implements the
43
         * <b>ChangeCapabilityDescriptionCommandTest_1</b> definition.
43
	 * <b>ChangeCapabilityDescriptionCommandTest_1</b> definition.
44
         */
44
	 */
45
    public static Test suite()
45
	public static Test suite()
46
    {
46
	{
47
	HyadesTestSuite changeCapabilityDescriptionCommandTest_1 = new HyadesTestSuite(
47
		HyadesTestSuite changeCapabilityDescriptionCommandTest_1 = new HyadesTestSuite(
48
		"ChangeCapabilityDescriptionCommandTest_1");
48
				"ChangeCapabilityDescriptionCommandTest_1");
49
	changeCapabilityDescriptionCommandTest_1.setArbiter(
49
		changeCapabilityDescriptionCommandTest_1.setArbiter(
50
		DefaultTestArbiter.INSTANCE).setId(
50
				DefaultTestArbiter.INSTANCE).setId(
51
		"C448865E2C0E25D849A80E0043DF11DB");
51
				"C448865E2C0E25D849A80E0043DF11DB");
52
52
53
	changeCapabilityDescriptionCommandTest_1
53
		changeCapabilityDescriptionCommandTest_1
54
		.addTest(new ChangeCapabilityDescriptionCommandTest_1(
54
				.addTest(new ChangeCapabilityDescriptionCommandTest_1(
55
			"testChangeCapabilityDescription"));
55
						"testChangeCapabilityDescription"));
56
56
57
	return changeCapabilityDescriptionCommandTest_1;
57
		return changeCapabilityDescriptionCommandTest_1;
58
    }
58
	}
59
59
60
    /**
60
	/**
61
         * @see junit.framework.TestCase#setUp()
61
	 * @see junit.framework.TestCase#setUp()
62
         */
62
	 */
63
    protected void setUp() throws Exception
63
	protected void setUp() throws Exception
64
    {
64
	{
65
	super.setUp();
65
		super.setUp();
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * @see junit.framework.TestCase#tearDown()
69
	 * @see junit.framework.TestCase#tearDown()
70
         */
70
	 */
71
    protected void tearDown() throws Exception
71
	protected void tearDown() throws Exception
72
    {
72
	{
73
    }
73
	}
74
74
75
    /**
75
	/**
76
         * When description node exists in wsdl targetnamespace schema, So
76
	 * When description node exists in wsdl targetnamespace schema, So change
77
         * change the user information element value
77
	 * the user information element value
78
         * 
78
	 * 
79
         * @throws Exception
79
	 * @throws Exception
80
         */
80
	 */
81
    public void testChangeCapabilityDescription() throws Exception
81
	public void testChangeCapabilityDescription() throws Exception
82
    {
82
	{
83
	String newDescription = "Server capability";
83
		String newDescription = "Server capability";
84
84
85
	ChangeCapabilityDescriptionCommand command = new ChangeCapabilityDescriptionCommand(
85
		ChangeCapabilityDescriptionCommand command = new ChangeCapabilityDescriptionCommand(
86
		capabilityDomain, newDescription);
86
				capabilityDomain, newDescription);
87
	command.execute();
87
		command.execute();
88
88
89
	// Verify the changes
89
		// Verify the changes
90
	assertNotNull(capabilityDomain.getDescriptionNode());
90
		assertNotNull(capabilityDomain.getDescriptionNode());
91
	assertEquals(newDescription, capabilityDomain.getDescriptionNode()
91
		assertEquals(newDescription, capabilityDomain.getDescriptionNode()
92
		.getData());
92
				.getData());
93
	assertEquals(newDescription, capabilityDomain.getCapability()
93
		assertEquals(newDescription, capabilityDomain.getCapability()
94
		.getDescription());
94
				.getDescription());
95
    }
95
	}
96
96
97
}
97
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/overview/ChangeCapabilityDescriptionCommandTest_2.java (-88 / +88 lines)
Lines 21-26 Link Here
21
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.overview.internal.ChangeCapabilityDescriptionCommand;
21
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.overview.internal.ChangeCapabilityDescriptionCommand;
22
import org.eclipse.tptp.wsdm.tooling.editor.capability.test.Activator;
22
import org.eclipse.tptp.wsdm.tooling.editor.capability.test.Activator;
23
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
23
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
24
import org.eclipse.wst.wsdl.Definition;
24
import org.eclipse.xsd.XSDAnnotation;
25
import org.eclipse.xsd.XSDAnnotation;
25
import org.eclipse.xsd.XSDSchema;
26
import org.eclipse.xsd.XSDSchema;
26
27
Lines 30-123 Link Here
30
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/overview/command/ChangeCapabilityDescriptionCommandTest_2.testsuite</i>.
31
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/overview/command/ChangeCapabilityDescriptionCommandTest_2.testsuite</i>.
31
 */
32
 */
32
public class ChangeCapabilityDescriptionCommandTest_2 extends
33
public class ChangeCapabilityDescriptionCommandTest_2 extends
33
	OverviewCommandTestModel
34
		OverviewCommandTestModel
34
{
35
{
35
    /**
36
	/**
36
         * Constructor for ChangeCapabilityDescriptionCommandTest_2.
37
	 * Constructor for ChangeCapabilityDescriptionCommandTest_2.
37
         * 
38
	 * 
38
         * @param name
39
	 * @param name
39
         */
40
	 */
40
    public ChangeCapabilityDescriptionCommandTest_2(String name)
41
	public ChangeCapabilityDescriptionCommandTest_2(String name)
41
    {
42
	{
42
	super(name, Activator.PLUGIN_ID + "/"
43
		super(name, Activator.PLUGIN_ID + "/"
43
		+ "testfiles/capability/command/overview/MyDescription_2.mcap");
44
				+ "testfiles/capability/command/overview/MyDescription_2.mcap");
44
    }
45
	}
45
46
46
    /**
47
	/**
47
         * Returns the JUnit test suite that implements the
48
	 * Returns the JUnit test suite that implements the
48
         * <b>ChangeCapabilityDescriptionCommandTest_2</b> definition.
49
	 * <b>ChangeCapabilityDescriptionCommandTest_2</b> definition.
49
         */
50
	 */
50
    public static Test suite()
51
	public static Test suite()
51
    {
52
	{
52
	HyadesTestSuite changeCapabilityDescriptionCommandTest_2 = new HyadesTestSuite(
53
		HyadesTestSuite changeCapabilityDescriptionCommandTest_2 = new HyadesTestSuite(
53
		"ChangeCapabilityDescriptionCommandTest_2");
54
				"ChangeCapabilityDescriptionCommandTest_2");
54
	changeCapabilityDescriptionCommandTest_2.setArbiter(
55
		changeCapabilityDescriptionCommandTest_2.setArbiter(
55
		DefaultTestArbiter.INSTANCE).setId(
56
				DefaultTestArbiter.INSTANCE).setId(
56
		"C448865E2C0E25D85B5644F043DF11DB");
57
				"C448865E2C0E25D85B5644F043DF11DB");
57
58
58
	changeCapabilityDescriptionCommandTest_2
59
		changeCapabilityDescriptionCommandTest_2
59
		.addTest(new ChangeCapabilityDescriptionCommandTest_2(
60
				.addTest(new ChangeCapabilityDescriptionCommandTest_2(
60
			"testChangeCapabilityDescription"));
61
						"testChangeCapabilityDescription"));
61
62
62
	return changeCapabilityDescriptionCommandTest_2;
63
		return changeCapabilityDescriptionCommandTest_2;
63
    }
64
	}
64
65
65
    /**
66
	/**
66
         * @see junit.framework.TestCase#setUp()
67
	 * @see junit.framework.TestCase#setUp()
67
         */
68
	 */
68
    protected void setUp() throws Exception
69
	protected void setUp() throws Exception
69
    {
70
	{
70
	super.setUp();
71
		super.setUp();
71
    }
72
	}
72
73
73
    /**
74
	/**
74
         * @see junit.framework.TestCase#tearDown()
75
	 * @see junit.framework.TestCase#tearDown()
75
         */
76
	 */
76
    protected void tearDown() throws Exception
77
	protected void tearDown() throws Exception
77
    {
78
	{
78
    }
79
	}
79
80
80
    /**
81
	/**
81
         * When wsdl targetnamespace schema exists, but no XSD annotations
82
	 * When wsdl targetnamespace schema exists, but no XSD annotations exists.
82
         * exists. This should create new XSD annotation and add a new
83
	 * This should create new XSD annotation and add a new description node
83
         * description node
84
	 * 
84
         * 
85
	 * @throws Exception
85
         * @throws Exception
86
	 */
86
         */
87
	public void testChangeCapabilityDescription() throws Exception
87
    public void testChangeCapabilityDescription() throws Exception
88
	{
88
    {
89
		String newDescription = "WAS capability";
89
	String newDescription = "WAS capability";
90
90
91
		// There should be no XSD annotation in WSDL schema
91
	// There should be no XSD annotation in WSDL schema
92
		Definition definition = capabilityDomain.getCapability()
92
	XSDSchema tnsSchema = WsdlUtils.createOrFindSchema(capabilityDomain
93
				.getDefinition();
93
		.getDefinition(), capabilityDomain.getDefinition()
94
		XSDSchema tnsSchema = WsdlUtils.createOrFindSchema(definition,
94
		.getTargetNamespace());
95
				definition.getTargetNamespace());
95
	List annotations = tnsSchema.getAnnotations();
96
		List annotations = tnsSchema.getAnnotations();
96
	assertNotNull(annotations);
97
		assertNotNull(annotations);
97
	assertEquals(0, annotations.size());
98
		assertEquals(0, annotations.size());
98
99
99
	// Change the description
100
		// Change the description
100
	ChangeCapabilityDescriptionCommand command = new ChangeCapabilityDescriptionCommand(
101
		ChangeCapabilityDescriptionCommand command = new ChangeCapabilityDescriptionCommand(
101
		capabilityDomain, newDescription);
102
				capabilityDomain, newDescription);
102
	command.execute();
103
		command.execute();
103
104
104
	// Verify the changes
105
		// Verify the changes
105
	assertNotNull(capabilityDomain.getDescriptionNode());
106
		assertNotNull(capabilityDomain.getDescriptionNode());
106
	assertEquals(newDescription, capabilityDomain.getDescriptionNode()
107
		assertEquals(newDescription, capabilityDomain.getDescriptionNode()
107
		.getData());
108
				.getData());
108
	assertEquals(newDescription, capabilityDomain.getCapability()
109
		assertEquals(newDescription, capabilityDomain.getCapability()
109
		.getDescription());
110
				.getDescription());
110
111
111
	// Verify that it has created new XSD annotation to the schema
112
		// Verify that it has created new XSD annotation to the schema
112
	XSDSchema schema = WsdlUtils.getSchema(
113
		XSDSchema schema = WsdlUtils.getSchema(definition, definition
113
		capabilityDomain.getDefinition(), capabilityDomain
114
				.getTargetNamespace());
114
			.getDefinition().getTargetNamespace());
115
		List newAnnotations = schema.getAnnotations();
115
	List newAnnotations = schema.getAnnotations();
116
		assertNotNull(newAnnotations);
116
	assertNotNull(newAnnotations);
117
		assertEquals(1, newAnnotations.size());
117
	assertEquals(1, newAnnotations.size());
118
118
119
		XSDAnnotation annotation = (XSDAnnotation) annotations.get(0);
119
	XSDAnnotation annotation = (XSDAnnotation) annotations.get(0);
120
		assertTrue(annotation.getElement().hasChildNodes());
120
	assertTrue(annotation.getElement().hasChildNodes());
121
	}
121
    }
122
122
123
}
123
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/ChangeTopicNameCommandTest.java (-50 / +50 lines)
Lines 25-79 Link Here
25
 */
25
 */
26
public class ChangeTopicNameCommandTest extends HyadesTestCase
26
public class ChangeTopicNameCommandTest extends HyadesTestCase
27
{
27
{
28
    /**
28
	/**
29
         * Constructor for ChangeTopicNameCommandTest.
29
	 * Constructor for ChangeTopicNameCommandTest.
30
         * 
30
	 * 
31
         * @param name
31
	 * @param name
32
         */
32
	 */
33
    public ChangeTopicNameCommandTest(String name)
33
	public ChangeTopicNameCommandTest(String name)
34
    {
34
	{
35
	super(name);
35
		super(name);
36
    }
36
	}
37
37
38
    /**
38
	/**
39
         * Returns the JUnit test suite that implements the
39
	 * Returns the JUnit test suite that implements the
40
         * <b>ChangeTopicNameCommandTest</b> definition.
40
	 * <b>ChangeTopicNameCommandTest</b> definition.
41
         */
41
	 */
42
    public static Test suite()
42
	public static Test suite()
43
    {
43
	{
44
	HyadesTestSuite changeTopicNameCommandTest = new HyadesTestSuite(
44
		HyadesTestSuite changeTopicNameCommandTest = new HyadesTestSuite(
45
		"ChangeTopicNameCommandTest");
45
				"ChangeTopicNameCommandTest");
46
	changeTopicNameCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
46
		changeTopicNameCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
47
		.setId("C254CB80544979D7F9EDC96042F611DB");
47
				.setId("C254CB80544979D7F9EDC96042F611DB");
48
48
49
	changeTopicNameCommandTest.addTest(new ChangeTopicNameCommandTest(
49
		changeTopicNameCommandTest.addTest(new ChangeTopicNameCommandTest(
50
		"testChangeTopicName"));
50
				"testChangeTopicName"));
51
51
52
	return changeTopicNameCommandTest;
52
		return changeTopicNameCommandTest;
53
    }
53
	}
54
54
55
    /**
55
	/**
56
         * @see junit.framework.TestCase#setUp()
56
	 * @see junit.framework.TestCase#setUp()
57
         */
57
	 */
58
    protected void setUp() throws Exception
58
	protected void setUp() throws Exception
59
    {
59
	{
60
    }
60
	}
61
61
62
    /**
62
	/**
63
         * @see junit.framework.TestCase#tearDown()
63
	 * @see junit.framework.TestCase#tearDown()
64
         */
64
	 */
65
    protected void tearDown() throws Exception
65
	protected void tearDown() throws Exception
66
    {
66
	{
67
    }
67
	}
68
68
69
    /**
69
	/**
70
         * testChangeTopicName
70
	 * testChangeTopicName
71
         * 
71
	 * 
72
         * @throws Exception
72
	 * @throws Exception
73
         */
73
	 */
74
    public void testChangeTopicName() throws Exception
74
	public void testChangeTopicName() throws Exception
75
    {
75
	{
76
	// Enter your code here
76
		// Enter your code here
77
    }
77
	}
78
78
79
}
79
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/RemoveTopicCommandTest.java (-50 / +50 lines)
Lines 24-78 Link Here
24
 */
24
 */
25
public class RemoveTopicCommandTest extends HyadesTestCase
25
public class RemoveTopicCommandTest extends HyadesTestCase
26
{
26
{
27
    /**
27
	/**
28
         * Constructor for RemoveTopicCommandTest.
28
	 * Constructor for RemoveTopicCommandTest.
29
         * 
29
	 * 
30
         * @param name
30
	 * @param name
31
         */
31
	 */
32
    public RemoveTopicCommandTest(String name)
32
	public RemoveTopicCommandTest(String name)
33
    {
33
	{
34
	super(name);
34
		super(name);
35
    }
35
	}
36
36
37
    /**
37
	/**
38
         * Returns the JUnit test suite that implements the
38
	 * Returns the JUnit test suite that implements the
39
         * <b>RemoveTopicCommandTest</b> definition.
39
	 * <b>RemoveTopicCommandTest</b> definition.
40
         */
40
	 */
41
    public static Test suite()
41
	public static Test suite()
42
    {
42
	{
43
	HyadesTestSuite removeTopicCommandTest = new HyadesTestSuite(
43
		HyadesTestSuite removeTopicCommandTest = new HyadesTestSuite(
44
		"RemoveTopicCommandTest");
44
				"RemoveTopicCommandTest");
45
	removeTopicCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
45
		removeTopicCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
46
		"C254CB80544979D70C13051042F711DB");
46
				"C254CB80544979D70C13051042F711DB");
47
47
48
	removeTopicCommandTest.addTest(new RemoveTopicCommandTest(
48
		removeTopicCommandTest.addTest(new RemoveTopicCommandTest(
49
		"testRemoveTopic"));
49
				"testRemoveTopic"));
50
50
51
	return removeTopicCommandTest;
51
		return removeTopicCommandTest;
52
    }
52
	}
53
53
54
    /**
54
	/**
55
         * @see junit.framework.TestCase#setUp()
55
	 * @see junit.framework.TestCase#setUp()
56
         */
56
	 */
57
    protected void setUp() throws Exception
57
	protected void setUp() throws Exception
58
    {
58
	{
59
    }
59
	}
60
60
61
    /**
61
	/**
62
         * @see junit.framework.TestCase#tearDown()
62
	 * @see junit.framework.TestCase#tearDown()
63
         */
63
	 */
64
    protected void tearDown() throws Exception
64
	protected void tearDown() throws Exception
65
    {
65
	{
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * testRemoveTopic
69
	 * testRemoveTopic
70
         * 
70
	 * 
71
         * @throws Exception
71
	 * @throws Exception
72
         */
72
	 */
73
    public void testRemoveTopic() throws Exception
73
	public void testRemoveTopic() throws Exception
74
    {
74
	{
75
	// Enter your code here
75
		// Enter your code here
76
    }
76
	}
77
77
78
}
78
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/RemoveTopicNamespaceCommandTest.java (-51 / +51 lines)
Lines 25-80 Link Here
25
 */
25
 */
26
public class RemoveTopicNamespaceCommandTest extends HyadesTestCase
26
public class RemoveTopicNamespaceCommandTest extends HyadesTestCase
27
{
27
{
28
    /**
28
	/**
29
         * Constructor for RemoveTopicNamespaceCommandTest.
29
	 * Constructor for RemoveTopicNamespaceCommandTest.
30
         * 
30
	 * 
31
         * @param name
31
	 * @param name
32
         */
32
	 */
33
    public RemoveTopicNamespaceCommandTest(String name)
33
	public RemoveTopicNamespaceCommandTest(String name)
34
    {
34
	{
35
	super(name);
35
		super(name);
36
    }
36
	}
37
37
38
    /**
38
	/**
39
         * Returns the JUnit test suite that implements the
39
	 * Returns the JUnit test suite that implements the
40
         * <b>RemoveTopicNamespaceCommandTest</b> definition.
40
	 * <b>RemoveTopicNamespaceCommandTest</b> definition.
41
         */
41
	 */
42
    public static Test suite()
42
	public static Test suite()
43
    {
43
	{
44
	HyadesTestSuite removeTopicNamespaceCommandTest = new HyadesTestSuite(
44
		HyadesTestSuite removeTopicNamespaceCommandTest = new HyadesTestSuite(
45
		"RemoveTopicNamespaceCommandTest");
45
				"RemoveTopicNamespaceCommandTest");
46
	removeTopicNamespaceCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
46
		removeTopicNamespaceCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
47
		.setId("C254CB80544979D71D4A103042F711DB");
47
				.setId("C254CB80544979D71D4A103042F711DB");
48
48
49
	removeTopicNamespaceCommandTest
49
		removeTopicNamespaceCommandTest
50
		.addTest(new RemoveTopicNamespaceCommandTest(
50
				.addTest(new RemoveTopicNamespaceCommandTest(
51
			"testRemoveTopicNamespace"));
51
						"testRemoveTopicNamespace"));
52
52
53
	return removeTopicNamespaceCommandTest;
53
		return removeTopicNamespaceCommandTest;
54
    }
54
	}
55
55
56
    /**
56
	/**
57
         * @see junit.framework.TestCase#setUp()
57
	 * @see junit.framework.TestCase#setUp()
58
         */
58
	 */
59
    protected void setUp() throws Exception
59
	protected void setUp() throws Exception
60
    {
60
	{
61
    }
61
	}
62
62
63
    /**
63
	/**
64
         * @see junit.framework.TestCase#tearDown()
64
	 * @see junit.framework.TestCase#tearDown()
65
         */
65
	 */
66
    protected void tearDown() throws Exception
66
	protected void tearDown() throws Exception
67
    {
67
	{
68
    }
68
	}
69
69
70
    /**
70
	/**
71
         * testRemoveTopicNamespace
71
	 * testRemoveTopicNamespace
72
         * 
72
	 * 
73
         * @throws Exception
73
	 * @throws Exception
74
         */
74
	 */
75
    public void testRemoveTopicNamespace() throws Exception
75
	public void testRemoveTopicNamespace() throws Exception
76
    {
76
	{
77
	// Enter your code here
77
		// Enter your code here
78
    }
78
	}
79
79
80
}
80
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/AddRootTopicCommandTest.java (-50 / +50 lines)
Lines 24-78 Link Here
24
 */
24
 */
25
public class AddRootTopicCommandTest extends HyadesTestCase
25
public class AddRootTopicCommandTest extends HyadesTestCase
26
{
26
{
27
    /**
27
	/**
28
         * Constructor for AddRootTopicCommandTest.
28
	 * Constructor for AddRootTopicCommandTest.
29
         * 
29
	 * 
30
         * @param name
30
	 * @param name
31
         */
31
	 */
32
    public AddRootTopicCommandTest(String name)
32
	public AddRootTopicCommandTest(String name)
33
    {
33
	{
34
	super(name);
34
		super(name);
35
    }
35
	}
36
36
37
    /**
37
	/**
38
         * Returns the JUnit test suite that implements the
38
	 * Returns the JUnit test suite that implements the
39
         * <b>AddRootTopicCommandTest</b> definition.
39
	 * <b>AddRootTopicCommandTest</b> definition.
40
         */
40
	 */
41
    public static Test suite()
41
	public static Test suite()
42
    {
42
	{
43
	HyadesTestSuite addRootTopicCommandTest = new HyadesTestSuite(
43
		HyadesTestSuite addRootTopicCommandTest = new HyadesTestSuite(
44
		"AddRootTopicCommandTest");
44
				"AddRootTopicCommandTest");
45
	addRootTopicCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
45
		addRootTopicCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
46
		"C254CB80544979D7E3D644E042F611DB");
46
				"C254CB80544979D7E3D644E042F611DB");
47
47
48
	addRootTopicCommandTest.addTest(new AddRootTopicCommandTest(
48
		addRootTopicCommandTest.addTest(new AddRootTopicCommandTest(
49
		"testAddRootTopic"));
49
				"testAddRootTopic"));
50
50
51
	return addRootTopicCommandTest;
51
		return addRootTopicCommandTest;
52
    }
52
	}
53
53
54
    /**
54
	/**
55
         * @see junit.framework.TestCase#setUp()
55
	 * @see junit.framework.TestCase#setUp()
56
         */
56
	 */
57
    protected void setUp() throws Exception
57
	protected void setUp() throws Exception
58
    {
58
	{
59
    }
59
	}
60
60
61
    /**
61
	/**
62
         * @see junit.framework.TestCase#tearDown()
62
	 * @see junit.framework.TestCase#tearDown()
63
         */
63
	 */
64
    protected void tearDown() throws Exception
64
	protected void tearDown() throws Exception
65
    {
65
	{
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * testAddRootTopic
69
	 * testAddRootTopic
70
         * 
70
	 * 
71
         * @throws Exception
71
	 * @throws Exception
72
         */
72
	 */
73
    public void testAddRootTopic() throws Exception
73
	public void testAddRootTopic() throws Exception
74
    {
74
	{
75
	// Enter your code here
75
		// Enter your code here
76
    }
76
	}
77
77
78
}
78
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/AllTopicCommandTest.java (-51 / +51 lines)
Lines 25-80 Link Here
25
 */
25
 */
26
public class AllTopicCommandTest extends HyadesTestCase
26
public class AllTopicCommandTest extends HyadesTestCase
27
{
27
{
28
    /**
28
	/**
29
         * Constructor for AllTopicCommandTest.
29
	 * Constructor for AllTopicCommandTest.
30
         * 
30
	 * 
31
         * @param name
31
	 * @param name
32
         */
32
	 */
33
    public AllTopicCommandTest(String name)
33
	public AllTopicCommandTest(String name)
34
    {
34
	{
35
	super(name);
35
		super(name);
36
    }
36
	}
37
37
38
    /**
38
	/**
39
         * Returns the JUnit test suite that implements the
39
	 * Returns the JUnit test suite that implements the <b>AllTopicCommandTest</b>
40
         * <b>AllTopicCommandTest</b> definition.
40
	 * definition.
41
         */
41
	 */
42
    public static Test suite()
42
	public static Test suite()
43
    {
43
	{
44
	HyadesTestSuite allTopicCommandTest = new HyadesTestSuite(
44
		HyadesTestSuite allTopicCommandTest = new HyadesTestSuite(
45
		"AllTopicCommandTest");
45
				"AllTopicCommandTest");
46
	allTopicCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
46
		allTopicCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
47
		"C254CB80544979D73FBFA08042F711DB");
47
				"C254CB80544979D73FBFA08042F711DB");
48
48
49
	allTopicCommandTest.addTest(HyadesJUnitRunner
49
		allTopicCommandTest.addTest(HyadesJUnitRunner
50
		.getTest(AddChildTopicCommandTest.class));
50
				.getTest(AddChildTopicCommandTest.class));
51
51
52
	allTopicCommandTest.addTest(HyadesJUnitRunner
52
		allTopicCommandTest.addTest(HyadesJUnitRunner
53
		.getTest(AddRootTopicCommandTest.class));
53
				.getTest(AddRootTopicCommandTest.class));
54
54
55
	allTopicCommandTest.addTest(HyadesJUnitRunner
55
		allTopicCommandTest.addTest(HyadesJUnitRunner
56
		.getTest(ChangeTopicNameCommandTest.class));
56
				.getTest(ChangeTopicNameCommandTest.class));
57
57
58
	allTopicCommandTest.addTest(HyadesJUnitRunner
58
		allTopicCommandTest.addTest(HyadesJUnitRunner
59
		.getTest(RemoveTopicCommandTest.class));
59
				.getTest(RemoveTopicCommandTest.class));
60
60
61
	allTopicCommandTest.addTest(HyadesJUnitRunner
61
		allTopicCommandTest.addTest(HyadesJUnitRunner
62
		.getTest(RemoveTopicNamespaceCommandTest.class));
62
				.getTest(RemoveTopicNamespaceCommandTest.class));
63
	return allTopicCommandTest;
63
		return allTopicCommandTest;
64
    }
64
	}
65
65
66
    /**
66
	/**
67
         * @see junit.framework.TestCase#setUp()
67
	 * @see junit.framework.TestCase#setUp()
68
         */
68
	 */
69
    protected void setUp() throws Exception
69
	protected void setUp() throws Exception
70
    {
70
	{
71
    }
71
	}
72
72
73
    /**
73
	/**
74
         * @see junit.framework.TestCase#tearDown()
74
	 * @see junit.framework.TestCase#tearDown()
75
         */
75
	 */
76
    protected void tearDown() throws Exception
76
	protected void tearDown() throws Exception
77
    {
77
	{
78
    }
78
	}
79
79
80
}
80
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/topic/AddChildTopicCommandTest.java (-50 / +50 lines)
Lines 24-78 Link Here
24
 */
24
 */
25
public class AddChildTopicCommandTest extends HyadesTestCase
25
public class AddChildTopicCommandTest extends HyadesTestCase
26
{
26
{
27
    /**
27
	/**
28
         * Constructor for AddChildTopicCommandTest.
28
	 * Constructor for AddChildTopicCommandTest.
29
         * 
29
	 * 
30
         * @param name
30
	 * @param name
31
         */
31
	 */
32
    public AddChildTopicCommandTest(String name)
32
	public AddChildTopicCommandTest(String name)
33
    {
33
	{
34
	super(name);
34
		super(name);
35
    }
35
	}
36
36
37
    /**
37
	/**
38
         * Returns the JUnit test suite that implements the
38
	 * Returns the JUnit test suite that implements the
39
         * <b>AddChildTopicCommandTest</b> definition.
39
	 * <b>AddChildTopicCommandTest</b> definition.
40
         */
40
	 */
41
    public static Test suite()
41
	public static Test suite()
42
    {
42
	{
43
	HyadesTestSuite addChildTopicCommandTest = new HyadesTestSuite(
43
		HyadesTestSuite addChildTopicCommandTest = new HyadesTestSuite(
44
		"AddChildTopicCommandTest");
44
				"AddChildTopicCommandTest");
45
	addChildTopicCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
45
		addChildTopicCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
46
		"C254CB80544979D7CF7A04F042F611DB");
46
				"C254CB80544979D7CF7A04F042F611DB");
47
47
48
	addChildTopicCommandTest.addTest(new AddChildTopicCommandTest(
48
		addChildTopicCommandTest.addTest(new AddChildTopicCommandTest(
49
		"testAddChildTopic"));
49
				"testAddChildTopic"));
50
50
51
	return addChildTopicCommandTest;
51
		return addChildTopicCommandTest;
52
    }
52
	}
53
53
54
    /**
54
	/**
55
         * @see junit.framework.TestCase#setUp()
55
	 * @see junit.framework.TestCase#setUp()
56
         */
56
	 */
57
    protected void setUp() throws Exception
57
	protected void setUp() throws Exception
58
    {
58
	{
59
    }
59
	}
60
60
61
    /**
61
	/**
62
         * @see junit.framework.TestCase#tearDown()
62
	 * @see junit.framework.TestCase#tearDown()
63
         */
63
	 */
64
    protected void tearDown() throws Exception
64
	protected void tearDown() throws Exception
65
    {
65
	{
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * testAddChildTopic
69
	 * testAddChildTopic
70
         * 
70
	 * 
71
         * @throws Exception
71
	 * @throws Exception
72
         */
72
	 */
73
    public void testAddChildTopic() throws Exception
73
	public void testAddChildTopic() throws Exception
74
    {
74
	{
75
	// Enter your code here
75
		// Enter your code here
76
    }
76
	}
77
77
78
}
78
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/TopicSpace2MetaDataDescriptorTest.java (-144 / +144 lines)
Lines 24-31 Link Here
24
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
24
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
25
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
25
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
26
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic;
26
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic;
27
import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.TopicSpace2MetaDataDescriptor;
27
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot;
28
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.DocumentRoot;
28
import org.eclipse.tptp.wsdm.tooling.util.internal.TopicSpace2MetaDataDescriptor;
29
29
30
/**
30
/**
31
 * Generated code for the test suite <b>TopicSpace2MetaDataDescriptorTest</b>
31
 * Generated code for the test suite <b>TopicSpace2MetaDataDescriptorTest</b>
Lines 34-180 Link Here
34
 */
34
 */
35
public class TopicSpace2MetaDataDescriptorTest extends UtilsCapabilityTestModel
35
public class TopicSpace2MetaDataDescriptorTest extends UtilsCapabilityTestModel
36
{
36
{
37
    /**
37
	/**
38
         * Constructor for TopicSpace2MetaDataDescriptorTest.
38
	 * Constructor for TopicSpace2MetaDataDescriptorTest.
39
         * 
39
	 * 
40
         * @param name
40
	 * @param name
41
         */
41
	 */
42
    public TopicSpace2MetaDataDescriptorTest(String name)
42
	public TopicSpace2MetaDataDescriptorTest(String name)
43
    {
43
	{
44
	super(name);
44
		super(name);
45
    }
45
	}
46
46
47
    /**
47
	/**
48
         * Returns the JUnit test suite that implements the
48
	 * Returns the JUnit test suite that implements the
49
         * <b>TopicSpace2MetaDataDescriptorTest</b> definition.
49
	 * <b>TopicSpace2MetaDataDescriptorTest</b> definition.
50
         */
50
	 */
51
    public static Test suite()
51
	public static Test suite()
52
    {
52
	{
53
	HyadesTestSuite topicSpace2MetaDataDescriptorTest = new HyadesTestSuite(
53
		HyadesTestSuite topicSpace2MetaDataDescriptorTest = new HyadesTestSuite(
54
		"TopicSpace2MetaDataDescriptorTest");
54
				"TopicSpace2MetaDataDescriptorTest");
55
	topicSpace2MetaDataDescriptorTest.setArbiter(
55
		topicSpace2MetaDataDescriptorTest.setArbiter(
56
		DefaultTestArbiter.INSTANCE).setId(
56
				DefaultTestArbiter.INSTANCE).setId(
57
		"C254CB80544979D7B4D2261042FA11DB");
57
				"C254CB80544979D7B4D2261042FA11DB");
58
58
59
	topicSpace2MetaDataDescriptorTest
59
		topicSpace2MetaDataDescriptorTest
60
		.addTest(new TopicSpace2MetaDataDescriptorTest(
60
				.addTest(new TopicSpace2MetaDataDescriptorTest(
61
			"testGetTopicExpressions_1"));
61
						"testGetTopicExpressions_1"));
62
62
63
	topicSpace2MetaDataDescriptorTest
63
		topicSpace2MetaDataDescriptorTest
64
		.addTest(new TopicSpace2MetaDataDescriptorTest(
64
				.addTest(new TopicSpace2MetaDataDescriptorTest(
65
			"testGetTopicExpressions_2"));
65
						"testGetTopicExpressions_2"));
66
66
67
	return topicSpace2MetaDataDescriptorTest;
67
		return topicSpace2MetaDataDescriptorTest;
68
    }
68
	}
69
69
70
    /**
70
	/**
71
         * @see junit.framework.TestCase#setUp()
71
	 * @see junit.framework.TestCase#setUp()
72
         */
72
	 */
73
    protected void setUp() throws Exception
73
	protected void setUp() throws Exception
74
    {
74
	{
75
	super.setUp();
75
		super.setUp();
76
    }
76
	}
77
77
78
    /**
78
	/**
79
         * @see junit.framework.TestCase#tearDown()
79
	 * @see junit.framework.TestCase#tearDown()
80
         */
80
	 */
81
    protected void tearDown() throws Exception
81
	protected void tearDown() throws Exception
82
    {
82
	{
83
    }
83
	}
84
84
85
    /**
85
	/**
86
         * This method will creates topic expressions for topicspaces. Since
86
	 * This method will creates topic expressions for topicspaces. Since
87
         * TopicExpression property will not available in RMD, it will create it
87
	 * TopicExpression property will not available in RMD, it will create it in
88
         * in RMD file.
88
	 * RMD file.
89
         * 
89
	 * 
90
         * @throws Exception
90
	 * @throws Exception
91
         */
91
	 */
92
    public void testGetTopicExpressions_1() throws Exception
92
	public void testGetTopicExpressions_1() throws Exception
93
    {
93
	{
94
	DocumentRoot root = capabilityDomain.getMetaDataDescriptor()
94
		DocumentRoot root = capabilityDomain.getCapability().getMetadata()
95
		.getDocumentRoot();
95
				.getDocumentRoot();
96
	Capability capability = capabilityDomain.getCapability();
96
		Capability capability = capabilityDomain.getCapability();
97
97
98
	EMap nsMap = root.getXMLNSPrefixMap();
98
		EMap nsMap = root.getXMLNSPrefixMap();
99
	List topicSpaces = createTopicSpaces(capabilityDomain);
99
		List topicSpaces = createTopicSpaces(capabilityDomain);
100
	TopicSpace2MetaDataDescriptor topic2Metadata = new TopicSpace2MetaDataDescriptor(
100
		TopicSpace2MetaDataDescriptor topic2Metadata = new TopicSpace2MetaDataDescriptor(
101
		nsMap, topicSpaces);
101
				nsMap, topicSpaces);
102
102
103
	// TODO Verify the created expressions
103
		// TODO Verify the created expressions
104
	String[] expressions = topic2Metadata.getTopicExpressions();
104
		String[] expressions = topic2Metadata.getTopicExpressions();
105
105
106
    }
106
	}
107
107
108
    /**
108
	/**
109
         * This method will creates topic expressions for topicspaces.
109
	 * This method will creates topic expressions for topicspaces.
110
         * 
110
	 * 
111
         * @throws Exception
111
	 * @throws Exception
112
         */
112
	 */
113
    public void testGetTopicExpressions_2() throws Exception
113
	public void testGetTopicExpressions_2() throws Exception
114
    {
114
	{
115
	DocumentRoot root = capabilityDomain.getMetaDataDescriptor()
115
		DocumentRoot root = capabilityDomain.getCapability().getMetadata()
116
		.getDocumentRoot();
116
				.getDocumentRoot();
117
	Capability capability = capabilityDomain.getCapability();
117
		Capability capability = capabilityDomain.getCapability();
118
118
119
	EMap nsMap = root.getXMLNSPrefixMap();
119
		EMap nsMap = root.getXMLNSPrefixMap();
120
	List topicSpaces = createTopicSpaces(capabilityDomain);
120
		List topicSpaces = createTopicSpaces(capabilityDomain);
121
	TopicSpace2MetaDataDescriptor topic2Metadata = new TopicSpace2MetaDataDescriptor(
121
		TopicSpace2MetaDataDescriptor topic2Metadata = new TopicSpace2MetaDataDescriptor(
122
		nsMap, topicSpaces);
122
				nsMap, topicSpaces);
123
123
124
	// TODO Verify the created expressions
124
		// TODO Verify the created expressions
125
	String[] expressions = topic2Metadata.getTopicExpressions();
125
		String[] expressions = topic2Metadata.getTopicExpressions();
126
    }
126
	}
127
127
128
    private List createTopicSpaces(CapabilityDomain capabilityDomain)
128
	private List createTopicSpaces(CapabilityDomain capabilityDomain)
129
    {
129
	{
130
	createStartTopicSpace(capabilityDomain);
130
		createStartTopicSpace(capabilityDomain);
131
	createStopTopicSpace(capabilityDomain);
131
		createStopTopicSpace(capabilityDomain);
132
	return capabilityDomain.getCapability().getTopicSpaces();
132
		return capabilityDomain.getCapability().getTopicSpaces();
133
    }
133
	}
134
134
135
    private void createStartTopicSpace(CapabilityDomain capabilityDomain)
135
	private void createStartTopicSpace(CapabilityDomain capabilityDomain)
136
    {
136
	{
137
	Topic rootTopic = getStartServerRootTopic();
137
		Topic rootTopic = getStartServerRootTopic();
138
	AddRootTopicCommand command = new AddRootTopicCommand(capabilityDomain,
138
		AddRootTopicCommand command = new AddRootTopicCommand(capabilityDomain,
139
		"http://start.org", rootTopic);
139
				"http://start.org", rootTopic);
140
	command.execute();
140
		command.execute();
141
    }
141
	}
142
142
143
    private void createStopTopicSpace(CapabilityDomain capabilityDomain)
143
	private void createStopTopicSpace(CapabilityDomain capabilityDomain)
144
    {
144
	{
145
	Topic rootTopic = getStopServerRootTopic();
145
		Topic rootTopic = getStopServerRootTopic();
146
	AddRootTopicCommand command = new AddRootTopicCommand(capabilityDomain,
146
		AddRootTopicCommand command = new AddRootTopicCommand(capabilityDomain,
147
		"http://stop.org", rootTopic);
147
				"http://stop.org", rootTopic);
148
	command.execute();
148
		command.execute();
149
    }
149
	}
150
150
151
    private Topic getStartServerRootTopic()
151
	private Topic getStartServerRootTopic()
152
    {
152
	{
153
	Topic rootTopic = TestUtils.createNewTopic("StartServer");
153
		Topic rootTopic = TestUtils.createNewTopic("StartServer");
154
	Topic childTopic = getStartDataResourceChildTopic();
154
		Topic childTopic = getStartDataResourceChildTopic();
155
	AddChildTopicCommand command = new AddChildTopicCommand(rootTopic,
155
		AddChildTopicCommand command = new AddChildTopicCommand(rootTopic,
156
		childTopic);
156
				childTopic);
157
	command.execute();
157
		command.execute();
158
	return rootTopic;
158
		return rootTopic;
159
    }
159
	}
160
160
161
    private Topic getStartDataResourceChildTopic()
161
	private Topic getStartDataResourceChildTopic()
162
    {
162
	{
163
	return TestUtils.createNewTopic("StartDataResource");
163
		return TestUtils.createNewTopic("StartDataResource");
164
    }
164
	}
165
165
166
    private Topic getStopServerRootTopic()
166
	private Topic getStopServerRootTopic()
167
    {
167
	{
168
	Topic rootTopic = TestUtils.createNewTopic("StopServer");
168
		Topic rootTopic = TestUtils.createNewTopic("StopServer");
169
	Topic childTopic = getStopDataResourceChildTopic();
169
		Topic childTopic = getStopDataResourceChildTopic();
170
	AddChildTopicCommand command = new AddChildTopicCommand(rootTopic,
170
		AddChildTopicCommand command = new AddChildTopicCommand(rootTopic,
171
		childTopic);
171
				childTopic);
172
	command.execute();
172
		command.execute();
173
	return rootTopic;
173
		return rootTopic;
174
    }
174
	}
175
175
176
    private Topic getStopDataResourceChildTopic()
176
	private Topic getStopDataResourceChildTopic()
177
    {
177
	{
178
	return TestUtils.createNewTopic("StopDataResource");
178
		return TestUtils.createNewTopic("StopDataResource");
179
    }
179
	}
180
}
180
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/UtilsCapabilityTestModel.java (-26 / +26 lines)
Lines 18-60 Link Here
18
18
19
public class UtilsCapabilityTestModel extends CapabilityTestModel
19
public class UtilsCapabilityTestModel extends CapabilityTestModel
20
{
20
{
21
    protected String CAPABILITY_NAME = "AppServer";
21
	protected String CAPABILITY_NAME = "AppServer";
22
22
23
    protected String CAPABILITY_NAMESPACE = "http://w3.ibm.com/";
23
	protected String CAPABILITY_NAMESPACE = "http://w3.ibm.com/";
24
24
25
    protected String PROPERTY_NAMESPACE = "http://w3.ibm.com/";
25
	protected String PROPERTY_NAMESPACE = "http://w3.ibm.com/";
26
26
27
    protected String[] PROPERTY_NAMES = new String[] { "home",
27
	protected String[] PROPERTY_NAMES = new String[] { "home",
28
	    "connectionPool", "TopicExpression" };
28
			"connectionPool", "TopicExpression" };
29
29
30
    protected String[] PROPERTY_TYPES = new String[] { "string", "int",
30
	protected String[] PROPERTY_TYPES = new String[] { "string", "int",
31
	    "TopicExpressionType" };
31
			"TopicExpressionType" };
32
32
33
    protected int[] MIN_OCCURS = new int[] { 1, 5, 0 };
33
	protected int[] MIN_OCCURS = new int[] { 1, 5, 0 };
34
34
35
    protected int[] MAX_OCCURS = new int[] { 1, 10, 0 };
35
	protected int[] MAX_OCCURS = new int[] { 1, 10, 0 };
36
36
37
    protected String[] OPERATION_NAMES = new String[] { "startServer",
37
	protected String[] OPERATION_NAMES = new String[] { "startServer",
38
	    "stopServer", "startApplication", "stopApplication" };
38
			"stopServer", "startApplication", "stopApplication" };
39
39
40
    protected String[] MODIFIABILITY = new String[] { MetaDataUtils.READ_ONLY,
40
	protected String[] MODIFIABILITY = new String[] { MetaDataUtils.READ_ONLY,
41
	    MetaDataUtils.WRITABLE, MetaDataUtils.READ_ONLY };
41
			MetaDataUtils.WRITABLE, MetaDataUtils.READ_ONLY };
42
42
43
    protected String[] MUTABILITY = new String[] { MetaDataUtils.CONSTANT,
43
	protected String[] MUTABILITY = new String[] { MetaDataUtils.CONSTANT,
44
	    MetaDataUtils.MUTABLE, MetaDataUtils.MUTABLE };
44
			MetaDataUtils.MUTABLE, MetaDataUtils.MUTABLE };
45
45
46
    protected String[] OPERATION_RETURN_TYPES = new String[] { "anyType",
46
	protected String[] OPERATION_RETURN_TYPES = new String[] { "anyType",
47
	    "anyType", "boolean", "boolean" };
47
			"anyType", "boolean", "boolean" };
48
48
49
    public UtilsCapabilityTestModel(String name)
49
	public UtilsCapabilityTestModel(String name)
50
    {
50
	{
51
	this(name, Activator.PLUGIN_ID + "/"
51
		this(name, Activator.PLUGIN_ID + "/"
52
		+ "testfiles/capability/util/AppServer.mcap");
52
				+ "testfiles/capability/util/AppServer.mcap");
53
    }
53
	}
54
54
55
    public UtilsCapabilityTestModel(String name, String CapabilityIFilePath)
55
	public UtilsCapabilityTestModel(String name, String CapabilityIFilePath)
56
    {
56
	{
57
	super(name, CapabilityIFilePath);
57
		super(name, CapabilityIFilePath);
58
    }
58
	}
59
59
60
}
60
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/WSDLUtilsTest.java (-226 / +226 lines)
Lines 31-261 Link Here
31
 */
31
 */
32
public class WSDLUtilsTest extends WSDLTestModel
32
public class WSDLUtilsTest extends WSDLTestModel
33
{
33
{
34
    /**
34
	/**
35
         * Constructor for WsdlUtilsTest.
35
	 * Constructor for WsdlUtilsTest.
36
         * 
36
	 * 
37
         * @param name
37
	 * @param name
38
         */
38
	 */
39
    public WSDLUtilsTest(String name)
39
	public WSDLUtilsTest(String name)
40
    {
40
	{
41
	super(name);
41
		super(name);
42
    }
42
	}
43
43
44
    /**
44
	/**
45
         * Returns the JUnit test suite that implements the <b>WsdlUtilsTest</b>
45
	 * Returns the JUnit test suite that implements the <b>WsdlUtilsTest</b>
46
         * definition.
46
	 * definition.
47
         */
47
	 */
48
    public static Test suite()
48
	public static Test suite()
49
    {
49
	{
50
	HyadesTestSuite WsdlUtilsTest = new HyadesTestSuite("WsdlUtilsTest");
50
		HyadesTestSuite WsdlUtilsTest = new HyadesTestSuite("WsdlUtilsTest");
51
	WsdlUtilsTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
51
		WsdlUtilsTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
52
		"EA3D854DD553CFEDB4436C0017F711DB");
52
				"EA3D854DD553CFEDB4436C0017F711DB");
53
53
54
	WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetWSDLOperation"));
54
		WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetWSDLOperation"));
55
	WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetPortType"));
55
		WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetPortType"));
56
	WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetOperationName"));
56
		WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetOperationName"));
57
	WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetSchema"));
57
		WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetSchema"));
58
	WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetXSDSchemas"));
58
		WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetXSDSchemas"));
59
	WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetNamespace"));
59
		WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetNamespace"));
60
	WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetPrefix"));
60
		WsdlUtilsTest.addTest(new WSDLUtilsTest("testGetPrefix"));
61
	WsdlUtilsTest.addTest(new WSDLUtilsTest("testIsNamespaceDefined"));
61
		WsdlUtilsTest.addTest(new WSDLUtilsTest("testIsNamespaceDefined"));
62
	WsdlUtilsTest
62
		WsdlUtilsTest
63
		.addTest(new WSDLUtilsTest("testGetTargetNamespacePrefix"));
63
				.addTest(new WSDLUtilsTest("testGetTargetNamespacePrefix"));
64
64
65
	return WsdlUtilsTest;
65
		return WsdlUtilsTest;
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * @see junit.framework.TestCase#setUp()
69
	 * @see junit.framework.TestCase#setUp()
70
         */
70
	 */
71
    protected void setUp() throws Exception
71
	protected void setUp() throws Exception
72
    {
72
	{
73
	super.setUp();
73
		super.setUp();
74
    }
74
	}
75
75
76
    /**
76
	/**
77
         * @see junit.framework.TestCase#tearDown()
77
	 * @see junit.framework.TestCase#tearDown()
78
         */
78
	 */
79
    protected void tearDown() throws Exception
79
	protected void tearDown() throws Exception
80
    {
80
	{
81
    }
81
	}
82
82
83
    /**
83
	/**
84
         * testGetWSDLOperation
84
	 * testGetWSDLOperation
85
         * 
85
	 * 
86
         * @throws Exception
86
	 * @throws Exception
87
         */
87
	 */
88
    public void testGetWSDLOperation() throws Exception
88
	public void testGetWSDLOperation() throws Exception
89
    {
89
	{
90
	Operation[] operations = WsdlUtils
90
		Operation[] operations = WsdlUtils
91
		.getWSDLOperation(ware_house_front_defintion);
91
				.getWSDLOperation(ware_house_front_defintion);
92
	assertNotNull(operations);
92
		assertNotNull(operations);
93
	assertEquals(OPERATION_NAMES.length, operations.length);
93
		assertEquals(OPERATION_NAMES.length, operations.length);
94
94
95
	for (int i = 0; i < OPERATION_NAMES.length; i++)
95
		for (int i = 0; i < OPERATION_NAMES.length; i++)
96
	{
96
		{
97
	    String opName = WsdlUtils.getOperationName(operations[i]);
97
			String opName = WsdlUtils.getOperationName(operations[i]);
98
	    assertEquals(OPERATION_NAMES[i], opName);
98
			assertEquals(OPERATION_NAMES[i], opName);
99
	}
99
		}
100
    }
100
	}
101
101
102
    /**
102
	/**
103
         * testGetPortType
103
	 * testGetPortType
104
         * 
104
	 * 
105
         * @throws Exception
105
	 * @throws Exception
106
         */
106
	 */
107
    public void testGetPortType() throws Exception
107
	public void testGetPortType() throws Exception
108
    {
108
	{
109
	PortType portType = WsdlUtils.getPortType(ware_house_front_defintion);
109
		PortType portType = WsdlUtils.getPortType(ware_house_front_defintion);
110
	assertNotNull(portType);
110
		assertNotNull(portType);
111
	QName qname = portType.getQName();
111
		QName qname = portType.getQName();
112
	String nsURI = qname.getNamespaceURI();
112
		String nsURI = qname.getNamespaceURI();
113
	String portName = qname.getLocalPart();
113
		String portName = qname.getLocalPart();
114
	assertEquals(TARGET_NS, nsURI);
114
		assertEquals(TARGET_NS, nsURI);
115
	assertEquals(PORT_TYPE_NAME, portName);
115
		assertEquals(PORT_TYPE_NAME, portName);
116
116
117
	List operations = portType.getEOperations();
117
		List operations = portType.getEOperations();
118
	assertNotNull(operations);
118
		assertNotNull(operations);
119
	assertEquals(OPERATION_NAMES.length, operations.size());
119
		assertEquals(OPERATION_NAMES.length, operations.size());
120
    }
120
	}
121
121
122
    /**
122
	/**
123
         * testGetOperationName
123
	 * testGetOperationName
124
         * 
124
	 * 
125
         * @throws Exception
125
	 * @throws Exception
126
         */
126
	 */
127
    public void testGetOperationName() throws Exception
127
	public void testGetOperationName() throws Exception
128
    {
128
	{
129
	Operation[] operations = WsdlUtils
129
		Operation[] operations = WsdlUtils
130
		.getWSDLOperation(ware_house_front_defintion);
130
				.getWSDLOperation(ware_house_front_defintion);
131
	assertNotNull(operations);
131
		assertNotNull(operations);
132
	assertEquals(OPERATION_NAMES.length, operations.length);
132
		assertEquals(OPERATION_NAMES.length, operations.length);
133
133
134
	for (int i = 0; i < OPERATION_NAMES.length; i++)
134
		for (int i = 0; i < OPERATION_NAMES.length; i++)
135
	{
135
		{
136
	    String opName = WsdlUtils.getOperationName(operations[i]);
136
			String opName = WsdlUtils.getOperationName(operations[i]);
137
	    assertEquals(OPERATION_NAMES[i], opName);
137
			assertEquals(OPERATION_NAMES[i], opName);
138
	}
138
		}
139
    }
139
	}
140
140
141
    /**
141
	/**
142
         * testGetSchema
142
	 * testGetSchema
143
         * 
143
	 * 
144
         * @throws Exception
144
	 * @throws Exception
145
         */
145
	 */
146
    public void testGetSchema() throws Exception
146
	public void testGetSchema() throws Exception
147
    {
147
	{
148
	for (int i = 0; i < XSD_SCHEMAS_DEFINED.length; i++)
148
		for (int i = 0; i < XSD_SCHEMAS_DEFINED.length; i++)
149
	{
149
		{
150
	    XSDSchema schema = WsdlUtils.getSchema(ware_house_front_defintion,
150
			XSDSchema schema = WsdlUtils.getSchema(ware_house_front_defintion,
151
		    XSD_SCHEMAS_DEFINED[i]);
151
					XSD_SCHEMAS_DEFINED[i]);
152
	    assertNotNull(schema);
152
			assertNotNull(schema);
153
	    assertEquals(XSD_SCHEMAS_DEFINED[i], schema.getTargetNamespace());
153
			assertEquals(XSD_SCHEMAS_DEFINED[i], schema.getTargetNamespace());
154
	}
154
		}
155
155
156
	String unknownSchema = "http://w3.ibm.com/unknownschema";
156
		String unknownSchema = "http://w3.ibm.com/unknownschema";
157
	XSDSchema schema = WsdlUtils.getSchema(ware_house_front_defintion,
157
		XSDSchema schema = WsdlUtils.getSchema(ware_house_front_defintion,
158
		unknownSchema);
158
				unknownSchema);
159
	assertNull(schema);
159
		assertNull(schema);
160
    }
160
	}
161
161
162
    /**
162
	/**
163
         * testGetXSDSchemas
163
	 * testGetXSDSchemas
164
         * 
164
	 * 
165
         * @throws Exception
165
	 * @throws Exception
166
         */
166
	 */
167
    public void testGetXSDSchemas() throws Exception
167
	public void testGetXSDSchemas() throws Exception
168
    {
168
	{
169
	XSDSchema[] schemas = WsdlUtils
169
		XSDSchema[] schemas = WsdlUtils
170
		.getXSDSchemas(ware_house_front_defintion);
170
				.getXSDSchemas(ware_house_front_defintion);
171
	assertNotNull(schemas);
171
		assertNotNull(schemas);
172
	assertEquals(XSD_SCHEMAS_DEFINED.length, schemas.length);
172
		assertEquals(XSD_SCHEMAS_DEFINED.length, schemas.length);
173
173
174
	for (int i = 0; i < XSD_SCHEMAS_DEFINED.length; i++)
174
		for (int i = 0; i < XSD_SCHEMAS_DEFINED.length; i++)
175
	{
175
		{
176
	    XSDSchema schema = schemas[i];
176
			XSDSchema schema = schemas[i];
177
	    assertEquals(XSD_SCHEMAS_DEFINED[i], schema.getTargetNamespace());
177
			assertEquals(XSD_SCHEMAS_DEFINED[i], schema.getTargetNamespace());
178
	}
178
		}
179
    }
179
	}
180
180
181
    /**
181
	/**
182
         * testGetNamespace
182
	 * testGetNamespace
183
         * 
183
	 * 
184
         * @throws Exception
184
	 * @throws Exception
185
         */
185
	 */
186
    public void testGetNamespace() throws Exception
186
	public void testGetNamespace() throws Exception
187
    {
187
	{
188
	for (int i = 0; i < NAMESPACE_DEFINED.length; i++)
188
		for (int i = 0; i < NAMESPACE_DEFINED.length; i++)
189
	{
189
		{
190
	    String prefix = NAMESPACE_DEFINED[i][0];
190
			String prefix = NAMESPACE_DEFINED[i][0];
191
	    String ns = NAMESPACE_DEFINED[i][1];
191
			String ns = NAMESPACE_DEFINED[i][1];
192
	    String resultNS = WsdlUtils.getNamespace(
192
			String resultNS = WsdlUtils.getNamespace(
193
		    ware_house_front_defintion, prefix);
193
					ware_house_front_defintion, prefix);
194
	    assertNotNull(resultNS);
194
			assertNotNull(resultNS);
195
	    assertEquals(ns, resultNS);
195
			assertEquals(ns, resultNS);
196
	}
196
		}
197
197
198
	String unknownPrefix = "Unknown";
198
		String unknownPrefix = "Unknown";
199
	String resultNS = WsdlUtils.getNamespace(ware_house_front_defintion,
199
		String resultNS = WsdlUtils.getNamespace(ware_house_front_defintion,
200
		unknownPrefix);
200
				unknownPrefix);
201
	assertNull(resultNS);
201
		assertNull(resultNS);
202
    }
202
	}
203
203
204
    /**
204
	/**
205
         * testGetPrefix
205
	 * testGetPrefix
206
         * 
206
	 * 
207
         * @throws Exception
207
	 * @throws Exception
208
         */
208
	 */
209
    public void testGetPrefix() throws Exception
209
	public void testGetPrefix() throws Exception
210
    {
210
	{
211
	for (int i = 0; i < NAMESPACE_DEFINED.length; i++)
211
		for (int i = 0; i < NAMESPACE_DEFINED.length; i++)
212
	{
212
		{
213
	    String prefix = NAMESPACE_DEFINED[i][0];
213
			String prefix = NAMESPACE_DEFINED[i][0];
214
	    String ns = NAMESPACE_DEFINED[i][1];
214
			String ns = NAMESPACE_DEFINED[i][1];
215
	    String resultPrefix = WsdlUtils.getPrefix(
215
			String resultPrefix = WsdlUtils.getPrefix(
216
		    ware_house_front_defintion, ns);
216
					ware_house_front_defintion, ns);
217
	    assertNotNull(resultPrefix);
217
			assertNotNull(resultPrefix);
218
	    assertEquals(prefix, resultPrefix);
218
			assertEquals(prefix, resultPrefix);
219
	}
219
		}
220
220
221
	String unknonNS = "http://w3.ibm.com/unknown";
221
		String unknonNS = "http://w3.ibm.com/unknown";
222
	String prefix = WsdlUtils.getPrefix(ware_house_front_defintion,
222
		String prefix = WsdlUtils.getPrefix(ware_house_front_defintion,
223
		unknonNS);
223
				unknonNS);
224
	assertNull(prefix);
224
		assertNull(prefix);
225
    }
225
	}
226
226
227
    /**
227
	/**
228
         * testIsNamespaceDefined
228
	 * testIsNamespaceDefined
229
         * 
229
	 * 
230
         * @throws Exception
230
	 * @throws Exception
231
         */
231
	 */
232
    public void testIsNamespaceDefined() throws Exception
232
	public void testIsNamespaceDefined() throws Exception
233
    {
233
	{
234
	for (int i = 0; i < NAMESPACE_DEFINED.length; i++)
234
		for (int i = 0; i < NAMESPACE_DEFINED.length; i++)
235
	{
235
		{
236
	    String ns = NAMESPACE_DEFINED[i][1];
236
			String ns = NAMESPACE_DEFINED[i][1];
237
	    boolean defined = WsdlUtils.isNamespaceDefined(
237
			boolean defined = WsdlUtils.isNamespaceDefined(
238
		    ware_house_front_defintion, ns);
238
					ware_house_front_defintion, ns);
239
	    assertEquals(true, defined);
239
			assertEquals(true, defined);
240
	}
240
		}
241
241
242
	String unknonNS = "http://w3.ibm.com/unknown";
242
		String unknonNS = "http://w3.ibm.com/unknown";
243
	boolean defined = WsdlUtils.isNamespaceDefined(
243
		boolean defined = WsdlUtils.isNamespaceDefined(
244
		ware_house_front_defintion, unknonNS);
244
				ware_house_front_defintion, unknonNS);
245
	assertEquals(false, defined);
245
		assertEquals(false, defined);
246
    }
246
	}
247
247
248
    /**
248
	/**
249
         * testGetTargetNamespacePrefix
249
	 * testGetTargetNamespacePrefix
250
         * 
250
	 * 
251
         * @throws Exception
251
	 * @throws Exception
252
         */
252
	 */
253
    public void testGetTargetNamespacePrefix() throws Exception
253
	public void testGetTargetNamespacePrefix() throws Exception
254
    {
254
	{
255
	String prefix = WsdlUtils
255
		String prefix = WsdlUtils
256
		.getTargetNamespacePrefix(ware_house_front_defintion);
256
				.getTargetNamespacePrefix(ware_house_front_defintion);
257
	assertNotNull(prefix);
257
		assertNotNull(prefix);
258
	assertEquals(TARGET_NS_PREFIX, prefix);
258
		assertEquals(TARGET_NS_PREFIX, prefix);
259
    }
259
	}
260
260
261
}
261
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/ValidationTest.java (-70 / +70 lines)
Lines 24-98 Link Here
24
 */
24
 */
25
public class ValidationTest extends HyadesTestCase
25
public class ValidationTest extends HyadesTestCase
26
{
26
{
27
    /**
27
	/**
28
         * Constructor for ValidationTest.
28
	 * Constructor for ValidationTest.
29
         * 
29
	 * 
30
         * @param name
30
	 * @param name
31
         */
31
	 */
32
    public ValidationTest(String name)
32
	public ValidationTest(String name)
33
    {
33
	{
34
	super(name);
34
		super(name);
35
    }
35
	}
36
36
37
    /**
37
	/**
38
         * Returns the JUnit test suite that implements the <b>ValidationTest</b>
38
	 * Returns the JUnit test suite that implements the <b>ValidationTest</b>
39
         * definition.
39
	 * definition.
40
         */
40
	 */
41
    public static Test suite()
41
	public static Test suite()
42
    {
42
	{
43
	HyadesTestSuite validationTest = new HyadesTestSuite("ValidationTest");
43
		HyadesTestSuite validationTest = new HyadesTestSuite("ValidationTest");
44
	validationTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
44
		validationTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
45
		"C254CB80544979D73CAB3F2042F811DB");
45
				"C254CB80544979D73CAB3F2042F811DB");
46
46
47
	validationTest.addTest(new ValidationTest("testIsNamespace"));
47
		validationTest.addTest(new ValidationTest("testIsNamespace"));
48
	validationTest.addTest(new ValidationTest("testIsNCName"));
48
		validationTest.addTest(new ValidationTest("testIsNCName"));
49
	validationTest.addTest(new ValidationTest("testIsQName"));
49
		validationTest.addTest(new ValidationTest("testIsQName"));
50
50
51
	return validationTest;
51
		return validationTest;
52
    }
52
	}
53
53
54
    /**
54
	/**
55
         * @see junit.framework.TestCase#setUp()
55
	 * @see junit.framework.TestCase#setUp()
56
         */
56
	 */
57
    protected void setUp() throws Exception
57
	protected void setUp() throws Exception
58
    {
58
	{
59
    }
59
	}
60
60
61
    /**
61
	/**
62
         * @see junit.framework.TestCase#tearDown()
62
	 * @see junit.framework.TestCase#tearDown()
63
         */
63
	 */
64
    protected void tearDown() throws Exception
64
	protected void tearDown() throws Exception
65
    {
65
	{
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * testIsNamespace
69
	 * testIsNamespace
70
         * 
70
	 * 
71
         * @throws Exception
71
	 * @throws Exception
72
         */
72
	 */
73
    public void testIsNamespace() throws Exception
73
	public void testIsNamespace() throws Exception
74
    {
74
	{
75
	// Enter your code here
75
		// Enter your code here
76
    }
76
	}
77
77
78
    /**
78
	/**
79
         * testIsNCName
79
	 * testIsNCName
80
         * 
80
	 * 
81
         * @throws Exception
81
	 * @throws Exception
82
         */
82
	 */
83
    public void testIsNCName() throws Exception
83
	public void testIsNCName() throws Exception
84
    {
84
	{
85
	// Enter your code here
85
		// Enter your code here
86
    }
86
	}
87
87
88
    /**
88
	/**
89
         * testIsQName
89
	 * testIsQName
90
         * 
90
	 * 
91
         * @throws Exception
91
	 * @throws Exception
92
         */
92
	 */
93
    public void testIsQName() throws Exception
93
	public void testIsQName() throws Exception
94
    {
94
	{
95
	// Enter your code here
95
		// Enter your code here
96
    }
96
	}
97
97
98
}
98
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/XSDUtilsTest.java (-172 / +172 lines)
Lines 28-204 Link Here
28
 */
28
 */
29
public class XSDUtilsTest extends XSDTestModel
29
public class XSDUtilsTest extends XSDTestModel
30
{
30
{
31
    /**
31
	/**
32
         * Constructor for XSDUtilsTest.
32
	 * Constructor for XSDUtilsTest.
33
         * 
33
	 * 
34
         * @param name
34
	 * @param name
35
         */
35
	 */
36
    public XSDUtilsTest(String name)
36
	public XSDUtilsTest(String name)
37
    {
37
	{
38
	super(name);
38
		super(name);
39
    }
39
	}
40
40
41
    /**
41
	/**
42
         * Returns the JUnit test suite that implements the <b>XsdUtilsTest</b>
42
	 * Returns the JUnit test suite that implements the <b>XsdUtilsTest</b>
43
         * definition.
43
	 * definition.
44
         */
44
	 */
45
    public static Test suite()
45
	public static Test suite()
46
    {
46
	{
47
	HyadesTestSuite XsdUtilsTest = new HyadesTestSuite("XsdUtilsTest");
47
		HyadesTestSuite XsdUtilsTest = new HyadesTestSuite("XsdUtilsTest");
48
	XsdUtilsTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
48
		XsdUtilsTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
49
		"EA3D854DD553CFEDDE801AE017F711DB");
49
				"EA3D854DD553CFEDDE801AE017F711DB");
50
50
51
	XsdUtilsTest.addTest(new XSDUtilsTest("testGetName"));
51
		XsdUtilsTest.addTest(new XSDUtilsTest("testGetName"));
52
	XsdUtilsTest.addTest(new XSDUtilsTest("testSetName"));
52
		XsdUtilsTest.addTest(new XSDUtilsTest("testSetName"));
53
	XsdUtilsTest.addTest(new XSDUtilsTest("testGetType"));
53
		XsdUtilsTest.addTest(new XSDUtilsTest("testGetType"));
54
	XsdUtilsTest.addTest(new XSDUtilsTest("testIsImportNSExists"));
54
		XsdUtilsTest.addTest(new XSDUtilsTest("testIsImportNSExists"));
55
	XsdUtilsTest.addTest(new XSDUtilsTest(
55
		XsdUtilsTest.addTest(new XSDUtilsTest(
56
		"testGetXSDElementDeclarationOfName"));
56
				"testGetXSDElementDeclarationOfName"));
57
	XsdUtilsTest.addTest(new XSDUtilsTest("testHasIncludeXSD"));
57
		XsdUtilsTest.addTest(new XSDUtilsTest("testHasIncludeXSD"));
58
	XsdUtilsTest.addTest(new XSDUtilsTest("testGetXSDInclude"));
58
		XsdUtilsTest.addTest(new XSDUtilsTest("testGetXSDInclude"));
59
59
60
	return XsdUtilsTest;
60
		return XsdUtilsTest;
61
    }
61
	}
62
62
63
    /**
63
	/**
64
         * @see junit.framework.TestCase#setUp()
64
	 * @see junit.framework.TestCase#setUp()
65
         */
65
	 */
66
    protected void setUp() throws Exception
66
	protected void setUp() throws Exception
67
    {
67
	{
68
	super.setUp();
68
		super.setUp();
69
    }
69
	}
70
70
71
    /**
71
	/**
72
         * @see junit.framework.TestCase#tearDown()
72
	 * @see junit.framework.TestCase#tearDown()
73
         */
73
	 */
74
    protected void tearDown() throws Exception
74
	protected void tearDown() throws Exception
75
    {
75
	{
76
    }
76
	}
77
77
78
    /**
78
	/**
79
         * testGetName
79
	 * testGetName
80
         * 
80
	 * 
81
         * @throws Exception
81
	 * @throws Exception
82
         */
82
	 */
83
    public void testGetName() throws Exception
83
	public void testGetName() throws Exception
84
    {
84
	{
85
	List features = XsdUtils.getXSDFeatureList(web_application_schema);
85
		List features = XsdUtils.getXSDFeatureList(web_application_schema);
86
	assertNotNull(features);
86
		assertNotNull(features);
87
	assertEquals(WEB_APP_ELEMENT_NAMES.length, features.size());
87
		assertEquals(WEB_APP_ELEMENT_NAMES.length, features.size());
88
88
89
	for (int i = 0; i < features.size(); i++)
89
		for (int i = 0; i < features.size(); i++)
90
	{
90
		{
91
	    XSDFeature feature = (XSDFeature) features.get(i);
91
			XSDFeature feature = (XSDFeature) features.get(i);
92
	    String name = XsdUtils.getName(feature);
92
			String name = XsdUtils.getName(feature);
93
	    assertEquals(WEB_APP_ELEMENT_NAMES[i], name);
93
			assertEquals(WEB_APP_ELEMENT_NAMES[i], name);
94
	}
94
		}
95
95
96
    }
96
	}
97
97
98
    /**
98
	/**
99
         * testSetName
99
	 * testSetName
100
         * 
100
	 * 
101
         * @throws Exception
101
	 * @throws Exception
102
         */
102
	 */
103
    public void testSetName() throws Exception
103
	public void testSetName() throws Exception
104
    {
104
	{
105
	List features = XsdUtils.getXSDFeatureList(web_application_schema);
105
		List features = XsdUtils.getXSDFeatureList(web_application_schema);
106
	assertNotNull(features);
106
		assertNotNull(features);
107
	assertEquals(WEB_APP_ELEMENT_NAMES.length, features.size());
107
		assertEquals(WEB_APP_ELEMENT_NAMES.length, features.size());
108
108
109
	XSDFeature feature = (XSDFeature) features.get(3);
109
		XSDFeature feature = (XSDFeature) features.get(3);
110
	String oldName = new String(XsdUtils.getName(feature));
110
		String oldName = new String(XsdUtils.getName(feature));
111
	String newName = "NewElement";
111
		String newName = "NewElement";
112
	XsdUtils.setName(feature, newName);
112
		XsdUtils.setName(feature, newName);
113
113
114
	XSDElementDeclaration oldElement = XsdUtils
114
		XSDElementDeclaration oldElement = XsdUtils
115
		.getXSDElementDeclarationOfName(web_application_schema, oldName);
115
				.getXSDElementDeclarationOfName(web_application_schema, oldName);
116
	assertNull(oldElement);
116
		assertNull(oldElement);
117
117
118
	XSDElementDeclaration newElement = XsdUtils
118
		XSDElementDeclaration newElement = XsdUtils
119
		.getXSDElementDeclarationOfName(web_application_schema, newName);
119
				.getXSDElementDeclarationOfName(web_application_schema, newName);
120
	assertNotNull(newElement);
120
		assertNotNull(newElement);
121
	assertEquals(feature, newElement);
121
		assertEquals(feature, newElement);
122
    }
122
	}
123
123
124
    /**
124
	/**
125
         * testGetType
125
	 * testGetType
126
         * 
126
	 * 
127
         * @throws Exception
127
	 * @throws Exception
128
         */
128
	 */
129
    public void testGetType() throws Exception
129
	public void testGetType() throws Exception
130
    {
130
	{
131
	List features = XsdUtils.getXSDFeatureList(web_application_schema);
131
		List features = XsdUtils.getXSDFeatureList(web_application_schema);
132
	assertNotNull(features);
132
		assertNotNull(features);
133
	assertEquals(WEB_APP_ELEMENT_NAMES.length, features.size());
133
		assertEquals(WEB_APP_ELEMENT_NAMES.length, features.size());
134
134
135
	for (int i = 0; i < features.size(); i++)
135
		for (int i = 0; i < features.size(); i++)
136
	{
136
		{
137
	    XSDFeature feature = (XSDFeature) features.get(i);
137
			XSDFeature feature = (XSDFeature) features.get(i);
138
	    String type = XsdUtils.getType(feature);
138
			String type = XsdUtils.getType(feature);
139
	    assertEquals(WEB_APP_ELEMENT_TYPES[i], type);
139
			assertEquals(WEB_APP_ELEMENT_TYPES[i], type);
140
	}
140
		}
141
    }
141
	}
142
142
143
    /**
143
	/**
144
         * testIsImportNSExists
144
	 * testIsImportNSExists
145
         * 
145
	 * 
146
         * @throws Exception
146
	 * @throws Exception
147
         */
147
	 */
148
    public void testIsImportNSExists() throws Exception
148
	public void testIsImportNSExists() throws Exception
149
    {
149
	{
150
	for (int i = 0; i < IMPORTED_NS.length; i++)
150
		for (int i = 0; i < IMPORTED_NS.length; i++)
151
	{
151
		{
152
	    boolean isExist = XsdUtils.isImportNSExists(web_application_schema,
152
			boolean isExist = XsdUtils.isImportNSExists(web_application_schema,
153
		    IMPORTED_NS[i]);
153
					IMPORTED_NS[i]);
154
	    assertEquals(true, isExist);
154
			assertEquals(true, isExist);
155
	}
155
		}
156
156
157
	String unknownNS = "http://w3.ibm.com/unknown";
157
		String unknownNS = "http://w3.ibm.com/unknown";
158
	boolean isExist = XsdUtils.isImportNSExists(web_application_schema,
158
		boolean isExist = XsdUtils.isImportNSExists(web_application_schema,
159
		unknownNS);
159
				unknownNS);
160
	assertEquals(false, isExist);
160
		assertEquals(false, isExist);
161
    }
161
	}
162
162
163
    /**
163
	/**
164
         * testGetXSDElementDeclarationOfName
164
	 * testGetXSDElementDeclarationOfName
165
         * 
165
	 * 
166
         * @throws Exception
166
	 * @throws Exception
167
         */
167
	 */
168
    public void testGetXSDElementDeclarationOfName() throws Exception
168
	public void testGetXSDElementDeclarationOfName() throws Exception
169
    {
169
	{
170
	List features = XsdUtils.getXSDFeatureList(web_application_schema);
170
		List features = XsdUtils.getXSDFeatureList(web_application_schema);
171
	assertNotNull(features);
171
		assertNotNull(features);
172
	assertEquals(WEB_APP_ELEMENT_NAMES.length, features.size());
172
		assertEquals(WEB_APP_ELEMENT_NAMES.length, features.size());
173
173
174
	for (int i = 0; i < features.size(); i++)
174
		for (int i = 0; i < features.size(); i++)
175
	{
175
		{
176
	    XSDFeature feature = (XSDFeature) features.get(i);
176
			XSDFeature feature = (XSDFeature) features.get(i);
177
	    XSDElementDeclaration element = XsdUtils
177
			XSDElementDeclaration element = XsdUtils
178
		    .getXSDElementDeclarationOfName(web_application_schema,
178
					.getXSDElementDeclarationOfName(web_application_schema,
179
			    WEB_APP_ELEMENT_NAMES[i]);
179
							WEB_APP_ELEMENT_NAMES[i]);
180
	    assertEquals(feature, element);
180
			assertEquals(feature, element);
181
	}
181
		}
182
    }
182
	}
183
183
184
    /**
184
	/**
185
         * testHasIncludeXSD
185
	 * testHasIncludeXSD
186
         * 
186
	 * 
187
         * @throws Exception
187
	 * @throws Exception
188
         */
188
	 */
189
    public void testHasIncludeXSD() throws Exception
189
	public void testHasIncludeXSD() throws Exception
190
    {
190
	{
191
	// Enter your code here
191
		// Enter your code here
192
    }
192
	}
193
193
194
    /**
194
	/**
195
         * testGetXSDInclude
195
	 * testGetXSDInclude
196
         * 
196
	 * 
197
         * @throws Exception
197
	 * @throws Exception
198
         */
198
	 */
199
    public void testGetXSDInclude() throws Exception
199
	public void testGetXSDInclude() throws Exception
200
    {
200
	{
201
	// Enter your code here
201
		// Enter your code here
202
    }
202
	}
203
203
204
}
204
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/Definition2CapabilityTest.java (-159 / +157 lines)
Lines 15-21 Link Here
15
15
16
import junit.framework.Test;
16
import junit.framework.Test;
17
17
18
import org.eclipse.emf.ecore.xml.type.internal.QName;
19
import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
18
import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
20
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
19
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
21
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
20
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
Lines 32-194 Link Here
32
 */
31
 */
33
public class Definition2CapabilityTest extends UtilsCapabilityTestModel
32
public class Definition2CapabilityTest extends UtilsCapabilityTestModel
34
{
33
{
35
    /**
34
	/**
36
         * Constructor for Definition2CapabilityTest.
35
	 * Constructor for Definition2CapabilityTest.
37
         * 
36
	 * 
38
         * @param name
37
	 * @param name
39
         */
38
	 */
40
39
41
    public Definition2CapabilityTest(String name)
40
	public Definition2CapabilityTest(String name)
42
    {
41
	{
43
	super(name);
42
		super(name);
44
    }
43
	}
45
44
46
    /**
45
	/**
47
         * Returns the JUnit test suite that implements the
46
	 * Returns the JUnit test suite that implements the
48
         * <b>Definition2CapabilityTest</b> definition.
47
	 * <b>Definition2CapabilityTest</b> definition.
49
         */
48
	 */
50
    public static Test suite()
49
	public static Test suite()
51
    {
50
	{
52
	HyadesTestSuite definition2CapabilityTest = new HyadesTestSuite(
51
		HyadesTestSuite definition2CapabilityTest = new HyadesTestSuite(
53
		"Definition2CapabilityTest");
52
				"Definition2CapabilityTest");
54
	definition2CapabilityTest.setArbiter(DefaultTestArbiter.INSTANCE)
53
		definition2CapabilityTest.setArbiter(DefaultTestArbiter.INSTANCE)
55
		.setId("EFF2985B4634B8E38994F84017E611DB");
54
				.setId("EFF2985B4634B8E38994F84017E611DB");
56
55
57
	definition2CapabilityTest.addTest(new Definition2CapabilityTest(
56
		definition2CapabilityTest.addTest(new Definition2CapabilityTest(
58
		"testGetCapabilityInfo"));
57
				"testGetCapabilityInfo"));
59
	definition2CapabilityTest.addTest(new Definition2CapabilityTest(
58
		definition2CapabilityTest.addTest(new Definition2CapabilityTest(
60
		"testGetCapabilityProperties"));
59
				"testGetCapabilityProperties"));
61
	definition2CapabilityTest.addTest(new Definition2CapabilityTest(
60
		definition2CapabilityTest.addTest(new Definition2CapabilityTest(
62
		"testGetPropertyMetadata"));
61
				"testGetPropertyMetadata"));
63
	definition2CapabilityTest.addTest(new Definition2CapabilityTest(
62
		definition2CapabilityTest.addTest(new Definition2CapabilityTest(
64
		"testGetCapabilityOperation"));
63
				"testGetCapabilityOperation"));
65
	definition2CapabilityTest.addTest(new Definition2CapabilityTest(
64
		definition2CapabilityTest.addTest(new Definition2CapabilityTest(
66
		"testGetCapabilityTopics"));
65
				"testGetCapabilityTopics"));
67
66
68
	return definition2CapabilityTest;
67
		return definition2CapabilityTest;
69
    }
68
	}
70
69
71
    /**
70
	/**
72
         * @see junit.framework.TestCase#setUp()
71
	 * @see junit.framework.TestCase#setUp()
73
         */
72
	 */
74
    protected void setUp() throws Exception
73
	protected void setUp() throws Exception
75
    {
74
	{
76
	super.setUp();
75
		super.setUp();
77
    }
76
	}
78
77
79
    /**
78
	/**
80
         * @see junit.framework.TestCase#tearDown()
79
	 * @see junit.framework.TestCase#tearDown()
81
         */
80
	 */
82
    protected void tearDown() throws Exception
81
	protected void tearDown() throws Exception
83
    {
82
	{
84
    }
83
	}
85
84
86
    /**
85
	/**
87
         * testGetCapabilityInfo
86
	 * testGetCapabilityInfo
88
         * 
87
	 * 
89
         * @throws Exception
88
	 * @throws Exception
90
         */
89
	 */
91
    public void testGetCapabilityInfo() throws Exception
90
	public void testGetCapabilityInfo() throws Exception
92
    {
91
	{
93
	String capName = capabilityDomain.getCapability().getName();
92
		String capName = capabilityDomain.getCapability().getName();
94
	String namespace = capabilityDomain.getCapability().getNamespace();
93
		String namespace = capabilityDomain.getCapability().getNamespace();
95
	assertEquals(CAPABILITY_NAME, capName);
94
		assertEquals(CAPABILITY_NAME, capName);
96
	assertEquals(CAPABILITY_NAMESPACE, namespace);
95
		assertEquals(CAPABILITY_NAMESPACE, namespace);
97
    }
96
	}
98
97
99
    /**
98
	/**
100
         * testGetCapabilityProperties
99
	 * testGetCapabilityProperties
101
         * 
100
	 * 
102
         * @throws Exception
101
	 * @throws Exception
103
         */
102
	 */
104
    public void testGetCapabilityProperties() throws Exception
103
	public void testGetCapabilityProperties() throws Exception
105
    {
104
	{
106
	List properties = capabilityDomain.getCapability().getProperties();
105
		List properties = capabilityDomain.getCapability().getProperties();
107
	assertNotNull(properties);
106
		assertNotNull(properties);
108
	assertEquals(PROPERTY_NAMES.length, properties.size());
107
		assertEquals(PROPERTY_NAMES.length, properties.size());
109
	for (int i = 0; i < properties.size(); i++)
108
		for (int i = 0; i < properties.size(); i++)
110
	{
109
		{
111
	    Object object = properties.get(i);
110
			Object object = properties.get(i);
112
	    assertNotNull(object);
111
			assertNotNull(object);
113
	    assertTrue(object instanceof Property);
112
			assertTrue(object instanceof Property);
114
	    Property property = (Property) object;
113
			Property property = (Property) object;
115
	    XSDElementDeclaration element = property.getElement();
114
			XSDElementDeclaration element = property.getElement();
116
	    assertNotNull(element);
115
			assertNotNull(element);
117
	    String elementNS = element.getTargetNamespace();
116
			String elementNS = element.getTargetNamespace();
118
	    String propName = XsdUtils.getName(element);
117
			String propName = XsdUtils.getName(element);
119
	    String propType = XsdUtils.getType(element);
118
			String propType = XsdUtils.getType(element);
120
	    assertEquals(PROPERTY_NAMES[i], propName);
119
			assertEquals(PROPERTY_NAMES[i], propName);
121
	    assertEquals(PROPERTY_TYPES[i], propType);
120
			assertEquals(PROPERTY_TYPES[i], propType);
122
	}
121
		}
123
    }
122
	}
124
123
125
    /**
124
	/**
126
         * testGetPropertyMetadata
125
	 * testGetPropertyMetadata
127
         * 
126
	 * 
128
         * @throws Exception
127
	 * @throws Exception
129
         */
128
	 */
130
    public void testGetPropertyMetadata() throws Exception
129
	public void testGetPropertyMetadata() throws Exception
131
    {
130
	{
132
	List properties = capabilityDomain.getCapability().getProperties();
131
		List properties = capabilityDomain.getCapability().getProperties();
133
	assertNotNull(properties);
132
		assertNotNull(properties);
134
	assertEquals(PROPERTY_NAMES.length, properties.size());
133
		assertEquals(PROPERTY_NAMES.length, properties.size());
135
	for (int i = 0; i < properties.size(); i++)
134
		for (int i = 0; i < properties.size(); i++)
136
	{
135
		{
137
	    Object object = properties.get(i);
136
			Object object = properties.get(i);
138
	    assertNotNull(object);
137
			assertNotNull(object);
139
	    assertTrue(object instanceof Property);
138
			assertTrue(object instanceof Property);
140
	    Property property = (Property) object;
139
			Property property = (Property) object;
141
	    PropertyType metadata = property.getMetaData();
140
			PropertyType metadata = property.getMetaData();
142
	    assertNotNull(metadata);
141
			assertNotNull(metadata);
143
	    QName qname = (QName) metadata.getName();
142
			String qname = metadata.getName();
144
	    String propName = qname.getLocalPart();
143
			String propName = TestUtils.extractName(qname);
145
	    String ns = qname.getNamespaceURI();
144
			String mutability = metadata.getMutability().getLiteral();
146
	    String mutability = metadata.getMutability().getLiteral();
145
			String modifiability = metadata.getModifiability().getLiteral();
147
	    String modifiability = metadata.getModifiability().getLiteral();
146
			assertEquals(PROPERTY_NAMES[i], propName);
148
	    assertEquals(PROPERTY_NAMES[i], propName);
147
			assertEquals(MUTABILITY[i], mutability);
149
	    assertEquals(MUTABILITY[i], mutability);
148
			assertEquals(MODIFIABILITY[i], modifiability);
150
	    assertEquals(MODIFIABILITY[i], modifiability);
149
151
150
			// TODO Check for CapabilityName, ValidValues, StaticValues,
152
	    // TODO Check for CapabilityName, ValidValues, StaticValues,
151
			// Metrics etc.
153
                // Metrics etc.
152
		}
154
	}
153
	}
155
    }
154
156
155
	/**
157
    /**
156
	 * testGetCapabilityOperation
158
         * testGetCapabilityOperation
157
	 * 
159
         * 
158
	 * @throws Exception
160
         * @throws Exception
159
	 */
161
         */
160
	public void testGetCapabilityOperation() throws Exception
162
    public void testGetCapabilityOperation() throws Exception
161
	{
163
    {
162
		List operations = capabilityDomain.getCapability().getOperations();
164
	List operations = capabilityDomain.getCapability().getOperations();
163
		assertNotNull(operations);
165
	assertNotNull(operations);
164
		assertEquals(OPERATION_NAMES.length, operations.size());
166
	assertEquals(OPERATION_NAMES.length, operations.size());
165
		for (int i = 0; i < operations.size(); i++)
167
	for (int i = 0; i < operations.size(); i++)
166
		{
168
	{
167
			Object object = operations.get(i);
169
	    Object object = operations.get(i);
168
			assertNotNull(object);
170
	    assertNotNull(object);
169
			assertTrue(object instanceof Operation);
171
	    assertTrue(object instanceof Operation);
170
			Operation operation = (Operation) object;
172
	    Operation operation = (Operation) object;
171
			String opName = WsdlUtils.getOperationName(operation);
173
	    String opName = WsdlUtils.getOperationName(operation);
172
			XSDElementDeclaration returnTypeDeclaration = WsdlUtils
174
	    XSDElementDeclaration returnTypeDeclaration = WsdlUtils
173
					.getReturnTypeElement(operation);
175
		    .getReturnTypeElement(operation);
174
			String returnType = XsdUtils.getType(returnTypeDeclaration);
176
	    String returnType = XsdUtils.getType(returnTypeDeclaration);
175
			assertEquals(OPERATION_NAMES[i], opName);
177
	    assertEquals(OPERATION_NAMES[i], opName);
176
			assertEquals(OPERATION_RETURN_TYPES[i], returnType);
178
	    assertEquals(OPERATION_RETURN_TYPES[i], returnType);
177
179
178
			// TODO Write the code for paramater checking
180
	    // TODO Write the code for paramater checking
179
		}
181
	}
180
	}
182
    }
181
183
182
	/**
184
    /**
183
	 * testGetCapabilityTopics
185
         * testGetCapabilityTopics
184
	 * 
186
         * 
185
	 * @throws Exception
187
         * @throws Exception
186
	 */
188
         */
187
	public void testGetCapabilityTopics() throws Exception
189
    public void testGetCapabilityTopics() throws Exception
188
	{
190
    {
189
		// Enter your code here
191
	// Enter your code here
190
	}
192
    }
193
191
194
}
192
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/MetaDataUtilsTest.java (-210 / +156 lines)
Lines 17-27 Link Here
17
17
18
import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
18
import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
19
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
19
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
20
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.FormMetric;
21
import org.eclipse.tptp.wsdm.tooling.editor.capability.model.test.RMDTestModel;
20
import org.eclipse.tptp.wsdm.tooling.editor.capability.model.test.RMDTestModel;
22
import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils;
21
import org.eclipse.tptp.wsdm.tooling.editor.capability.util.internal.MetaDataUtils;
23
import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory;
24
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
25
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType;
22
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType;
26
23
27
/**
24
/**
Lines 30-241 Link Here
30
 */
27
 */
31
public class MetaDataUtilsTest extends RMDTestModel
28
public class MetaDataUtilsTest extends RMDTestModel
32
{
29
{
33
    /**
30
	/**
34
         * Constructor for MetaDataUtilsTest.
31
	 * Constructor for MetaDataUtilsTest.
35
         * 
32
	 * 
36
         * @param name
33
	 * @param name
37
         */
34
	 */
38
    public MetaDataUtilsTest(String name)
35
	public MetaDataUtilsTest(String name)
39
    {
36
	{
40
	super(name);
37
		super(name);
41
    }
38
	}
42
39
43
    /**
40
	/**
44
         * Returns the JUnit test suite that implements the <b>MetaDataUtilsTest</b>
41
	 * Returns the JUnit test suite that implements the <b>MetaDataUtilsTest</b>
45
         * definition.
42
	 * definition.
46
         */
43
	 */
47
    public static Test suite()
44
	public static Test suite()
48
    {
45
	{
49
	HyadesTestSuite metaDataUtilsTest = new HyadesTestSuite(
46
		HyadesTestSuite metaDataUtilsTest = new HyadesTestSuite(
50
		"MetaDataUtilsTest");
47
				"MetaDataUtilsTest");
51
	metaDataUtilsTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
48
		metaDataUtilsTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
52
		"EA3D854DD553CFED9107305017F711DB");
49
				"EA3D854DD553CFED9107305017F711DB");
53
50
54
	metaDataUtilsTest
51
		metaDataUtilsTest
55
		.addTest(new MetaDataUtilsTest("testGetModifiability"));
52
				.addTest(new MetaDataUtilsTest("testGetModifiability"));
56
	metaDataUtilsTest.addTest(new MetaDataUtilsTest("testGetMutability"));
53
		metaDataUtilsTest.addTest(new MetaDataUtilsTest("testGetMutability"));
57
	metaDataUtilsTest.addTest(new MetaDataUtilsTest("testGetValidValues"));
54
		metaDataUtilsTest.addTest(new MetaDataUtilsTest("testGetValidValues"));
58
	metaDataUtilsTest.addTest(new MetaDataUtilsTest("testGetStaticValues"));
55
		metaDataUtilsTest.addTest(new MetaDataUtilsTest("testGetStaticValues"));
59
	metaDataUtilsTest.addTest(new MetaDataUtilsTest(
56
60
		"testHasMetricsCapability"));
57
		return metaDataUtilsTest;
61
	metaDataUtilsTest.addTest(new MetaDataUtilsTest("testGetMetric"));
58
	}
62
59
63
	return metaDataUtilsTest;
60
	/**
64
    }
61
	 * @see junit.framework.TestCase#setUp()
65
62
	 */
66
    /**
63
	protected void setUp() throws Exception
67
         * @see junit.framework.TestCase#setUp()
64
	{
68
         */
65
		super.setUp();
69
    protected void setUp() throws Exception
66
	}
70
    {
67
71
	super.setUp();
68
	/**
72
    }
69
	 * @see junit.framework.TestCase#tearDown()
73
70
	 */
74
    /**
71
	protected void tearDown() throws Exception
75
         * @see junit.framework.TestCase#tearDown()
72
	{
76
         */
73
	}
77
    protected void tearDown() throws Exception
74
78
    {
75
	/**
79
    }
76
	 * testGetModifiability
80
77
	 * 
81
    /**
78
	 * @throws Exception
82
         * testGetModifiability
79
	 */
83
         * 
80
	public void testGetModifiability() throws Exception
84
         * @throws Exception
81
	{
85
         */
82
		List propertyTypes = metaDescriptor.getProperty();
86
    public void testGetModifiability() throws Exception
83
		assertNotNull(propertyTypes);
87
    {
84
		assertEquals(NO_OF_PROPERTIES, propertyTypes.size());
88
	List propertyTypes = metaDescriptor.getProperty();
85
89
	assertNotNull(propertyTypes);
86
		PropertyType homeProperty = (PropertyType) propertyTypes.get(0);
90
	assertEquals(NO_OF_PROPERTIES, propertyTypes.size());
87
		String modifiability = MetaDataUtils.getModifiability(homeProperty);
91
88
		assertNotNull(modifiability);
92
	PropertyType homeProperty = (PropertyType) propertyTypes.get(0);
89
		assertEquals(home_metadata.modifiability, modifiability);
93
	String modifiability = MetaDataUtils.getModifiability(homeProperty);
90
94
	assertNotNull(modifiability);
91
		PropertyType connectionPoolProperty = (PropertyType) propertyTypes
95
	assertEquals(home_metadata.modifiability, modifiability);
92
				.get(1);
96
93
		modifiability = MetaDataUtils.getModifiability(connectionPoolProperty);
97
	PropertyType connectionPoolProperty = (PropertyType) propertyTypes
94
		assertNotNull(modifiability);
98
		.get(1);
95
		assertEquals(connectionPool_metadata.modifiability, modifiability);
99
	modifiability = MetaDataUtils.getModifiability(connectionPoolProperty);
96
	}
100
	assertNotNull(modifiability);
97
101
	assertEquals(connectionPool_metadata.modifiability, modifiability);
98
	/**
102
    }
99
	 * testGetMutability
103
100
	 * 
104
    /**
101
	 * @throws Exception
105
         * testGetMutability
102
	 */
106
         * 
103
	public void testGetMutability() throws Exception
107
         * @throws Exception
104
	{
108
         */
105
		List propertyTypes = metaDescriptor.getProperty();
109
    public void testGetMutability() throws Exception
106
		assertNotNull(propertyTypes);
110
    {
107
		assertEquals(NO_OF_PROPERTIES, propertyTypes.size());
111
	List propertyTypes = metaDescriptor.getProperty();
108
112
	assertNotNull(propertyTypes);
109
		PropertyType homeProperty = (PropertyType) propertyTypes.get(0);
113
	assertEquals(NO_OF_PROPERTIES, propertyTypes.size());
110
		String mutability = MetaDataUtils.getMutability(homeProperty);
114
111
		assertNotNull(mutability);
115
	PropertyType homeProperty = (PropertyType) propertyTypes.get(0);
112
		assertEquals(home_metadata.mutability, mutability);
116
	String mutability = MetaDataUtils.getMutability(homeProperty);
113
117
	assertNotNull(mutability);
114
		PropertyType connectionPoolProperty = (PropertyType) propertyTypes
118
	assertEquals(home_metadata.mutability, mutability);
115
				.get(1);
119
116
		mutability = MetaDataUtils.getMutability(connectionPoolProperty);
120
	PropertyType connectionPoolProperty = (PropertyType) propertyTypes
117
		assertNotNull(mutability);
121
		.get(1);
118
		assertEquals(connectionPool_metadata.mutability, mutability);
122
	mutability = MetaDataUtils.getMutability(connectionPoolProperty);
119
	}
123
	assertNotNull(mutability);
120
124
	assertEquals(connectionPool_metadata.mutability, mutability);
121
	/**
125
    }
122
	 * testGetValidValues
126
123
	 * 
127
    /**
124
	 * @throws Exception
128
         * testGetValidValues
125
	 */
129
         * 
126
	public void testGetValidValues() throws Exception
130
         * @throws Exception
127
	{
131
         */
128
		List propertyTypes = metaDescriptor.getProperty();
132
    public void testGetValidValues() throws Exception
129
		assertNotNull(propertyTypes);
133
    {
130
		assertEquals(NO_OF_PROPERTIES, propertyTypes.size());
134
	List propertyTypes = metaDescriptor.getProperty();
131
135
	assertNotNull(propertyTypes);
132
		PropertyType homeProperty = (PropertyType) propertyTypes.get(0);
136
	assertEquals(NO_OF_PROPERTIES, propertyTypes.size());
133
		Object[] validValues = MetaDataUtils.getValidValues(homeProperty
137
134
				.getValidValues());
138
	PropertyType homeProperty = (PropertyType) propertyTypes.get(0);
135
		assertNotNull(validValues);
139
	Object[] validValues = MetaDataUtils.getValidValues(homeProperty
136
		for (int i = 0; i < home_metadata.validValues.length; i++)
140
		.getValidValues());
137
		{
141
	assertNotNull(validValues);
138
			Object expected = home_metadata.validValues[i];
142
	for (int i = 0; i < home_metadata.validValues.length; i++)
139
			assertEquals(expected, validValues[i]);
143
	{
140
		}
144
	    Object expected = home_metadata.validValues[i];
141
145
	    assertEquals(expected, validValues[i]);
142
		PropertyType connectionPoolProperty = (PropertyType) propertyTypes
146
	}
143
				.get(1);
147
144
		validValues = MetaDataUtils.getValidValues(connectionPoolProperty
148
	PropertyType connectionPoolProperty = (PropertyType) propertyTypes
145
				.getValidValues());
149
		.get(1);
146
		assertNotNull(validValues);
150
	validValues = MetaDataUtils.getValidValues(connectionPoolProperty
147
		for (int i = 0; i < connectionPool_metadata.validValues.length; i++)
151
		.getValidValues());
148
		{
152
	assertNotNull(validValues);
149
			Object expected = connectionPool_metadata.validValues[i];
153
	for (int i = 0; i < connectionPool_metadata.validValues.length; i++)
150
			assertEquals(expected, validValues[i]);
154
	{
151
		}
155
	    Object expected = connectionPool_metadata.validValues[i];
152
	}
156
	    assertEquals(expected, validValues[i]);
153
157
	}
154
	/**
158
    }
155
	 * testGetStaticValues
159
156
	 * 
160
    /**
157
	 * @throws Exception
161
         * testGetStaticValues
158
	 */
162
         * 
159
	public void testGetStaticValues() throws Exception
163
         * @throws Exception
160
	{
164
         */
161
		List propertyTypes = metaDescriptor.getProperty();
165
    public void testGetStaticValues() throws Exception
162
		assertNotNull(propertyTypes);
166
    {
163
		assertEquals(NO_OF_PROPERTIES, propertyTypes.size());
167
	List propertyTypes = metaDescriptor.getProperty();
164
168
	assertNotNull(propertyTypes);
165
		PropertyType homeProperty = (PropertyType) propertyTypes.get(0);
169
	assertEquals(NO_OF_PROPERTIES, propertyTypes.size());
166
		Object[] staticValues = MetaDataUtils.getStaticValues(homeProperty
170
167
				.getStaticValues());
171
	PropertyType homeProperty = (PropertyType) propertyTypes.get(0);
168
		assertNotNull(staticValues);
172
	Object[] staticValues = MetaDataUtils.getStaticValues(homeProperty
169
		for (int i = 0; i < home_metadata.staticValues.length; i++)
173
		.getStaticValues());
170
		{
174
	assertNotNull(staticValues);
171
			Object expected = home_metadata.staticValues[i];
175
	for (int i = 0; i < home_metadata.staticValues.length; i++)
172
			assertEquals(expected, staticValues[i]);
176
	{
173
		}
177
	    Object expected = home_metadata.staticValues[i];
174
178
	    assertEquals(expected, staticValues[i]);
175
		PropertyType connectionPoolProperty = (PropertyType) propertyTypes
179
	}
176
				.get(1);
180
177
		staticValues = MetaDataUtils.getStaticValues(connectionPoolProperty
181
	PropertyType connectionPoolProperty = (PropertyType) propertyTypes
178
				.getStaticValues());
182
		.get(1);
179
		assertNotNull(staticValues);
183
	staticValues = MetaDataUtils.getStaticValues(connectionPoolProperty
180
		for (int i = 0; i < connectionPool_metadata.staticValues.length; i++)
184
		.getStaticValues());
181
		{
185
	assertNotNull(staticValues);
182
			Object expected = connectionPool_metadata.staticValues[i];
186
	for (int i = 0; i < connectionPool_metadata.staticValues.length; i++)
183
			assertEquals(expected, staticValues[i]);
187
	{
184
		}
188
	    Object expected = connectionPool_metadata.staticValues[i];
185
	}
189
	    assertEquals(expected, staticValues[i]);
190
	}
191
    }
192
193
    /**
194
         * testHasMetricsCapability
195
         * 
196
         * @throws Exception
197
         */
198
    public void testHasMetricsCapability() throws Exception
199
    {
200
	List propertyTypes = metaDescriptor.getProperty();
201
	assertNotNull(propertyTypes);
202
	assertEquals(NO_OF_PROPERTIES, propertyTypes.size());
203
204
	PropertyType homeProperty = (PropertyType) propertyTypes.get(0);
205
	boolean hasMetric = MetaDataUtils.hasMetricsCapability(homeProperty);
206
	assertEquals(home_metadata.hasMetric, hasMetric);
207
208
	PropertyType connectionPoolProperty = (PropertyType) propertyTypes
209
		.get(1);
210
	hasMetric = MetaDataUtils.hasMetricsCapability(connectionPoolProperty);
211
	assertEquals(connectionPool_metadata.hasMetric, hasMetric);
212
    }
213
214
    /**
215
         * testGetMetric
216
         * 
217
         * @throws Exception
218
         */
219
    public void testGetMetric() throws Exception
220
    {
221
	List propertyTypes = metaDescriptor.getProperty();
222
	assertNotNull(propertyTypes);
223
	assertEquals(NO_OF_PROPERTIES, propertyTypes.size());
224
225
	PropertyType connectionPoolProperty = (PropertyType) propertyTypes
226
		.get(1);
227
	Property property = CapabilitiesFactory.eINSTANCE.createProperty();
228
	property.setMetaData(connectionPoolProperty);
229
	FormMetric metric = MetaDataUtils.getMetric(null, property);
230
	assertNotNull(metric);
231
	assertEquals(connectionPool_metadata.metric.changeType, metric
232
		.getCType());
233
	assertEquals(connectionPool_metadata.metric.timeScope, metric
234
		.getTScope());
235
	assertEquals(connectionPool_metadata.metric.gatheringTime, metric
236
		.getGTime());
237
	assertEquals(connectionPool_metadata.metric.calculationInterval, metric
238
		.getCInterval());
239
    }
240
186
241
}
187
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/TestUtils.java (-110 / +125 lines)
Lines 24-36 Link Here
24
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.operation.internal.InputParameter;
24
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.operation.internal.InputParameter;
25
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataType;
25
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataType;
26
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataTypesCollection;
26
import org.eclipse.tptp.wsdm.tooling.editor.capability.pages.property.internal.DataTypesCollection;
27
import org.eclipse.tptp.wsdm.tooling.model.capabilities.CapabilitiesFactory;
27
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
28
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
28
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
29
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
29
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic;
30
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Topic;
30
import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace;
31
import org.eclipse.tptp.wsdm.tooling.model.capabilities.TopicSpace;
31
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType;
32
import org.eclipse.tptp.wsdm.tooling.model.metadataDescriptor.PropertyType;
32
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
33
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
33
import org.eclipse.tptp.wsdm.tooling.util.internal.TopicUtils;
34
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
34
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
35
import org.eclipse.wst.wsdl.Definition;
35
import org.eclipse.wst.wsdl.Definition;
36
import org.eclipse.wst.wsdl.Fault;
36
import org.eclipse.wst.wsdl.Fault;
Lines 46-159 Link Here
46
public class TestUtils
46
public class TestUtils
47
{
47
{
48
48
49
    public static XSDElementDeclaration createNewProperty()
49
	public static XSDElementDeclaration createNewProperty()
50
    {
50
	{
51
    DataTypesCollection instance = DataTypesCollection.getInstance();
51
		DataTypesCollection instance = DataTypesCollection.getInstance();
52
    DataType stringType = instance.getDataType("string");
52
		DataType stringType = instance.getDataType("string");
53
	XSDElementDeclaration newProperty = XSDFactory.eINSTANCE
53
		XSDElementDeclaration newProperty = XSDFactory.eINSTANCE
54
		.createXSDElementDeclaration();
54
				.createXSDElementDeclaration();
55
	newProperty.setName("dummy");
55
		newProperty.setName("dummy");
56
	newProperty.setTypeDefinition(stringType.getTypeDefinition());
56
		newProperty.setTypeDefinition(stringType.getTypeDefinition());
57
	return newProperty;
57
		return newProperty;
58
    }
58
	}
59
59
60
    public static DataType getDataType(String typeName)
60
	public static DataType getDataType(String typeName)
61
    {
61
	{
62
    DataTypesCollection instance = DataTypesCollection.getInstance();
62
		DataTypesCollection instance = DataTypesCollection.getInstance();
63
    DataType dataType = instance.getDataType(typeName);
63
		DataType dataType = instance.getDataType(typeName);
64
    return dataType;
64
		return dataType;
65
    }
65
	}
66
66
67
    public static List getComplexTypes(String xsdFilePath)
67
	public static List getComplexTypes(String xsdFilePath)
68
    {
68
	{
69
	IFile xsdFile = null;
69
		IFile xsdFile = null;
70
	try
70
		try
71
	{
71
		{
72
	    xsdFile = EclipseUtils.getIFile(xsdFilePath);
72
			xsdFile = EclipseUtils.getIFile(xsdFilePath);
73
	} catch (CoreException e)
73
		} catch (CoreException e)
74
	{
74
		{
75
	    throw new AssertionFailedError(
75
			throw new AssertionFailedError(
76
		    "Not able to find the file in workspace -- " + xsdFilePath);
76
					"Not able to find the file in workspace -- " + xsdFilePath);
77
	}
77
		}
78
	XSDSchema schema = XsdUtils.getSchema(xsdFile);
78
		XSDSchema schema = XsdUtils.getSchema(xsdFile);
79
	if (schema == null)
79
		if (schema == null)
80
	    throw new AssertionFailedError(
80
			throw new AssertionFailedError(
81
		    "Not able to get XSDSchema object from file -- "
81
					"Not able to get XSDSchema object from file -- "
82
			    + xsdFilePath);
82
							+ xsdFilePath);
83
	return schema.getTypeDefinitions();
83
		return schema.getTypeDefinitions();
84
    }
84
	}
85
85
86
    public static XSDElementDeclaration[] getXSDElementDeclarations(
86
	public static XSDElementDeclaration[] getXSDElementDeclarations(
87
	    XSDSchema schema)
87
			XSDSchema schema)
88
    {
88
	{
89
	return (XSDElementDeclaration[]) schema.getElementDeclarations()
89
		return (XSDElementDeclaration[]) schema.getElementDeclarations()
90
		.toArray(new XSDElementDeclaration[0]);
90
				.toArray(new XSDElementDeclaration[0]);
91
    }
91
	}
92
92
93
    public static Operation createNewOperation(Definition definition)
93
	public static Operation createNewOperation(Definition definition)
94
    {
94
	{
95
	NewTestOperation testOperation = new NewTestOperation(definition);
95
		NewTestOperation testOperation = new NewTestOperation(definition);
96
	return testOperation.getOperation();
96
		return testOperation.getOperation();
97
    }
97
	}
98
98
99
    public static Fault createNewException(Definition definition,
99
	public static Fault createNewException(Definition definition,
100
	    Operation operation)
100
			Operation operation)
101
    {
101
	{
102
	NewTestException testException = new NewTestException(definition,
102
		NewTestException testException = new NewTestException(definition,
103
		operation);
103
				operation);
104
	return testException.getFault();
104
		return testException.getFault();
105
    }
105
	}
106
106
107
    public static InputParameter createNewParameter(String paramName,
107
	public static InputParameter createNewParameter(String paramName,
108
	    DataType dataType)
108
			DataType dataType)
109
    {
109
	{
110
	NewTestParameter testParameter = new NewTestParameter(paramName,
110
		NewTestParameter testParameter = new NewTestParameter(paramName,
111
		dataType);
111
				dataType);
112
	return testParameter.getParameter();
112
		return testParameter.getParameter();
113
    }
113
	}
114
114
115
    public static PropertyType getPropertyType(Capability capability, QName name)
115
	public static PropertyType getPropertyType(Capability capability, QName name)
116
    {
116
	{
117
	List properties = capability.getProperties();
117
		List properties = capability.getProperties();
118
	for (int i = 0; i < properties.size(); i++)
118
		for (int i = 0; i < properties.size(); i++)
119
	{
119
		{
120
	    Property property = (Property) properties.get(i);
120
			Property property = (Property) properties.get(i);
121
	    PropertyType metadata = property.getMetaData();
121
			PropertyType metadata = property.getMetaData();
122
	    if (metadata.getName().equals(name))
122
			if (metadata.getName().equals(name))
123
		return metadata;
123
				return metadata;
124
	}
124
		}
125
	return null;
125
		return null;
126
    }
126
	}
127
127
128
    public static PropertyType getPropertyType(Capability capability,
128
	public static PropertyType getPropertyType(Capability capability,
129
	    String name)
129
			String propQName)
130
    {
130
	{
131
	List properties = capability.getProperties();
131
		List properties = capability.getProperties();
132
	for (int i = 0; i < properties.size(); i++)
132
		for (int i = 0; i < properties.size(); i++)
133
	{
133
		{
134
	    Property property = (Property) properties.get(i);
134
			Property property = (Property) properties.get(i);
135
	    PropertyType metadata = property.getMetaData();
135
			PropertyType metadata = property.getMetaData();
136
	    QName qname = (QName) metadata.getName();
136
			String propName = metadata.getName();
137
	    if (qname.getLocalPart().equals(name))
137
			if (propName.equals(propQName))
138
		return metadata;
138
				return metadata;
139
	}
139
		}
140
	return null;
140
		return null;
141
    }
141
	}
142
142
143
    public static Topic createNewTopic(String topicName)
143
	public static Topic createNewTopic(String topicName)
144
    {
144
	{
145
	Topic topic = TopicUtils.createNewTopic();
145
		Topic topic = CapabilitiesFactory.eINSTANCE.createTopic();
146
	topic.setName(topicName);
146
		topic.setName(topicName);
147
	return topic;
147
		return topic;
148
    }
148
	}
149
149
150
    public static TopicSpace createNewTopicSpace(String topicSpaceName,
150
	public static TopicSpace createNewTopicSpace(String topicSpaceName,
151
	    String topicSpaceNamespace)
151
			String topicSpaceNamespace)
152
    {
152
	{
153
	TopicSpace topicSpace = TopicUtils.createNewTopicSpace();
153
		TopicSpace topicSpace = CapabilitiesFactory.eINSTANCE
154
	topicSpace.setName(topicSpaceName);
154
				.createTopicSpace();
155
	topicSpace.setNamespace(topicSpaceNamespace);
155
		topicSpace.setName(topicSpaceName);
156
	return topicSpace;
156
		topicSpace.setNamespace(topicSpaceNamespace);
157
    }
157
		return topicSpace;
158
	}
159
160
	public static String extractPrefix(String str)
161
	{
162
		if (str == null || str.trim().equals("") || str.indexOf(':') == -1)
163
			return null;
164
		return str.substring(0, str.indexOf(':'));
165
	}
166
167
	public static String extractName(String str)
168
	{
169
		if (str == null || str.trim().equals("") || str.indexOf(':') == -1)
170
			return null;
171
		return str.substring(str.indexOf(':') + 1);
172
	}
158
173
159
}
174
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/PropertyMetaDataDescriptorTest.java (-222 / +221 lines)
Lines 28-254 Link Here
28
 */
28
 */
29
public class PropertyMetaDataDescriptorTest extends UtilsCapabilityTestModel
29
public class PropertyMetaDataDescriptorTest extends UtilsCapabilityTestModel
30
{
30
{
31
    /**
31
	/**
32
         * Constructor for PropertyMetaDataDescriptorTest.
32
	 * Constructor for PropertyMetaDataDescriptorTest.
33
         * 
33
	 * 
34
         * @param name
34
	 * @param name
35
         */
35
	 */
36
    public PropertyMetaDataDescriptorTest(String name)
36
	public PropertyMetaDataDescriptorTest(String name)
37
    {
37
	{
38
	super(name);
38
		super(name);
39
    }
39
	}
40
40
41
    /**
41
	/**
42
         * Returns the JUnit test suite that implements the
42
	 * Returns the JUnit test suite that implements the
43
         * <b>PropertyMetaDataDescriptorTest</b> definition.
43
	 * <b>PropertyMetaDataDescriptorTest</b> definition.
44
         */
44
	 */
45
    public static Test suite()
45
	public static Test suite()
46
    {
46
	{
47
	HyadesTestSuite propertyMetaDataDescriptorTest = new HyadesTestSuite(
47
		HyadesTestSuite propertyMetaDataDescriptorTest = new HyadesTestSuite(
48
		"PropertyMetaDataDescriptorTest");
48
				"PropertyMetaDataDescriptorTest");
49
	propertyMetaDataDescriptorTest.setArbiter(DefaultTestArbiter.INSTANCE)
49
		propertyMetaDataDescriptorTest.setArbiter(DefaultTestArbiter.INSTANCE)
50
		.setId("C254CB80544979D7FA9C155042F711DB");
50
				.setId("C254CB80544979D7FA9C155042F711DB");
51
51
52
	propertyMetaDataDescriptorTest
52
		propertyMetaDataDescriptorTest
53
		.addTest(new PropertyMetaDataDescriptorTest(
53
				.addTest(new PropertyMetaDataDescriptorTest(
54
			"testCreateNewPropertyType"));
54
						"testCreateNewPropertyType"));
55
	propertyMetaDataDescriptorTest
55
		propertyMetaDataDescriptorTest
56
		.addTest(new PropertyMetaDataDescriptorTest(
56
				.addTest(new PropertyMetaDataDescriptorTest(
57
			"testCreateTopicExpressionProperty"));
57
						"testCreateTopicExpressionProperty"));
58
	propertyMetaDataDescriptorTest
58
		propertyMetaDataDescriptorTest
59
		.addTest(new PropertyMetaDataDescriptorTest(
59
				.addTest(new PropertyMetaDataDescriptorTest(
60
			"testGetOrCreatePrefix"));
60
						"testGetOrCreatePrefix"));
61
	propertyMetaDataDescriptorTest
61
		propertyMetaDataDescriptorTest
62
		.addTest(new PropertyMetaDataDescriptorTest("testGetPrefix"));
62
				.addTest(new PropertyMetaDataDescriptorTest("testGetPrefix"));
63
	propertyMetaDataDescriptorTest
63
		propertyMetaDataDescriptorTest
64
		.addTest(new PropertyMetaDataDescriptorTest(
64
				.addTest(new PropertyMetaDataDescriptorTest(
65
			"testGetPropertyMetadata"));
65
						"testGetPropertyMetadata"));
66
	propertyMetaDataDescriptorTest
66
		propertyMetaDataDescriptorTest
67
		.addTest(new PropertyMetaDataDescriptorTest(
67
				.addTest(new PropertyMetaDataDescriptorTest(
68
			"testGetPropertyTypes"));
68
						"testGetPropertyTypes"));
69
	propertyMetaDataDescriptorTest
69
		propertyMetaDataDescriptorTest
70
		.addTest(new PropertyMetaDataDescriptorTest(
70
				.addTest(new PropertyMetaDataDescriptorTest(
71
			"testGetTopicExpressionProperty"));
71
						"testGetTopicExpressionProperty"));
72
	propertyMetaDataDescriptorTest
72
		propertyMetaDataDescriptorTest
73
		.addTest(new PropertyMetaDataDescriptorTest(
73
				.addTest(new PropertyMetaDataDescriptorTest(
74
			"testGetTopicspaces"));
74
						"testGetTopicspaces"));
75
	propertyMetaDataDescriptorTest
75
		propertyMetaDataDescriptorTest
76
		.addTest(new PropertyMetaDataDescriptorTest(
76
				.addTest(new PropertyMetaDataDescriptorTest(
77
			"testSaveTopicspaces"));
77
						"testSaveTopicspaces"));
78
78
79
	return propertyMetaDataDescriptorTest;
79
		return propertyMetaDataDescriptorTest;
80
    }
80
	}
81
81
82
    /**
82
	/**
83
         * @see junit.framework.TestCase#setUp()
83
	 * @see junit.framework.TestCase#setUp()
84
         */
84
	 */
85
    protected void setUp() throws Exception
85
	protected void setUp() throws Exception
86
    {
86
	{
87
	super.setUp();
87
		super.setUp();
88
    }
88
	}
89
89
90
    /**
90
	/**
91
         * @see junit.framework.TestCase#tearDown()
91
	 * @see junit.framework.TestCase#tearDown()
92
         */
92
	 */
93
    protected void tearDown() throws Exception
93
	protected void tearDown() throws Exception
94
    {
94
	{
95
    }
95
	}
96
96
97
    /**
97
	/**
98
         * testCreateNewPropertyType
98
	 * testCreateNewPropertyType
99
         * 
99
	 * 
100
         * @throws Exception
100
	 * @throws Exception
101
         */
101
	 */
102
    public void testCreateNewPropertyType() throws Exception
102
	public void testCreateNewPropertyType() throws Exception
103
    {
103
	{
104
	int oldPropSize = metaDataDescriptor.getMetadataDescriptorType()
104
		int oldPropSize = metaDataDescriptor.getMetadataDescriptorType()
105
		.getProperty().size();
105
				.getProperty().size();
106
106
107
	// Create new property type
107
		// Create new property type
108
	PropertyType propertyType = metaDataDescriptor.createNewPropertyType();
108
		PropertyType propertyType = metaDataDescriptor.createNewPropertyType();
109
109
110
	// Verify new property type
110
		// Verify new property type
111
	assertNotNull(propertyType);
111
		assertNotNull(propertyType);
112
	int newPropSize = metaDataDescriptor.getMetadataDescriptorType()
112
		int newPropSize = metaDataDescriptor.getMetadataDescriptorType()
113
		.getProperty().size();
113
				.getProperty().size();
114
	assertEquals(oldPropSize + 1, newPropSize);
114
		assertEquals(oldPropSize + 1, newPropSize);
115
    }
115
	}
116
116
117
    /**
117
	/**
118
         * testCreateTopicExpressionProperty
118
	 * testCreateTopicExpressionProperty
119
         * 
119
	 * 
120
         * @throws Exception
120
	 * @throws Exception
121
         */
121
	 */
122
    public void testCreateTopicExpressionProperty() throws Exception
122
	public void testCreateTopicExpressionProperty() throws Exception
123
    {
123
	{
124
	int oldPropSize = metaDataDescriptor.getMetadataDescriptorType()
124
		int oldPropSize = metaDataDescriptor.getMetadataDescriptorType()
125
		.getProperty().size();
125
				.getProperty().size();
126
126
127
	// Create topicExpressionProperty
127
		// Create topicExpressionProperty
128
	PropertyType topicExpressionProperty = metaDataDescriptor
128
		PropertyType topicExpressionProperty = metaDataDescriptor
129
		.createTopicExpressionProperty();
129
				.createTopicExpressionProperty();
130
130
131
	// Verify topicExpressionProperty
131
		// Verify topicExpressionProperty
132
	assertNotNull(topicExpressionProperty);
132
		assertNotNull(topicExpressionProperty);
133
	assertEquals(ModifiabilityType.READ_ONLY_LITERAL,
133
		assertEquals(ModifiabilityType.READ_ONLY_LITERAL,
134
		topicExpressionProperty.getModifiability());
134
				topicExpressionProperty.getModifiability());
135
	assertEquals(MutabilityType.MUTABLE_LITERAL, topicExpressionProperty
135
		assertEquals(MutabilityType.MUTABLE_LITERAL, topicExpressionProperty
136
		.getMutability());
136
				.getMutability());
137
	int newPropSize = metaDataDescriptor.getMetadataDescriptorType()
137
		int newPropSize = metaDataDescriptor.getMetadataDescriptorType()
138
		.getProperty().size();
138
				.getProperty().size();
139
	assertEquals(oldPropSize + 1, newPropSize);
139
		assertEquals(oldPropSize + 1, newPropSize);
140
    }
140
	}
141
141
142
    /**
142
	/**
143
         * testGetOrCreatePrefix
143
	 * testGetOrCreatePrefix
144
         * 
144
	 * 
145
         * @throws Exception
145
	 * @throws Exception
146
         */
146
	 */
147
    public void testGetOrCreatePrefix() throws Exception
147
	public void testGetOrCreatePrefix() throws Exception
148
    {
148
	{
149
	// Create a non-existing namespace
149
		// Create a non-existing namespace
150
	String namespace = "http://www.test.org";
150
		String namespace = "http://www.test.org";
151
	assertNull(metaDataDescriptor.getPrefix(namespace));
151
		assertNull(metaDataDescriptor.getPrefix(namespace));
152
152
153
	String newPrefix = metaDataDescriptor.getOrCreatePrefix(namespace);
153
		String newPrefix = metaDataDescriptor.getOrCreatePrefix(namespace);
154
154
155
	// Verify that it has created new prefix
155
		// Verify that it has created new prefix
156
	String prefix = metaDataDescriptor.getPrefix(namespace);
156
		String prefix = metaDataDescriptor.getPrefix(namespace);
157
	assertEquals(newPrefix, prefix);
157
		assertEquals(newPrefix, prefix);
158
    }
158
	}
159
159
160
    /**
160
	/**
161
         * testGetPrefix
161
	 * testGetPrefix
162
         * 
162
	 * 
163
         * @throws Exception
163
	 * @throws Exception
164
         */
164
	 */
165
    public void testGetPrefix() throws Exception
165
	public void testGetPrefix() throws Exception
166
    {
166
	{
167
	String namespace = WsdmConstants.MUWS_P1_NS;
167
		String namespace = WsdmConstants.MUWS_P1_NS;
168
	String prefix = metaDataDescriptor.getPrefix(namespace);
168
		String prefix = metaDataDescriptor.getPrefix(namespace);
169
	assertEquals("muws-p1", prefix);
169
		assertEquals("muws-p1", prefix);
170
    }
170
	}
171
171
172
    /**
172
	/**
173
         * testGetPropertyMetadata
173
	 * testGetPropertyMetadata
174
         * 
174
	 * 
175
         * @throws Exception
175
	 * @throws Exception
176
         */
176
	 */
177
    public void testGetPropertyMetadata() throws Exception
177
	public void testGetPropertyMetadata() throws Exception
178
    {
178
	{
179
	String name = PROPERTY_NAMES[0];
179
		String name = PROPERTY_NAMES[0];
180
	PropertyType metadata = metaDataDescriptor.getPropertyMetadata(name,
180
		PropertyType metadata = metaDataDescriptor.getPropertyMetadata(name,
181
		capability.getNamespace());
181
				capability.getNamespace());
182
182
183
	// Verify it
183
		// Verify it
184
	assertNotNull(metadata);
184
		assertNotNull(metadata);
185
185
186
	// TODO Verify the modifiability and mutability
186
		// TODO Verify the modifiability and mutability
187
    }
187
	}
188
188
189
    /**
189
	/**
190
         * testGetPropertyTypes
190
	 * testGetPropertyTypes
191
         * 
191
	 * 
192
         * @throws Exception
192
	 * @throws Exception
193
         */
193
	 */
194
    public void testGetPropertyTypes() throws Exception
194
	public void testGetPropertyTypes() throws Exception
195
    {
195
	{
196
	PropertyType[] propertyTypes = metaDataDescriptor.getPropertyTypes();
196
		PropertyType[] propertyTypes = metaDataDescriptor.getPropertyTypes();
197
197
198
	// Verify it
198
		// Verify it
199
	assertNotNull(propertyTypes);
199
		assertNotNull(propertyTypes);
200
200
201
	// TODO Chek the size for it
201
		// TODO Chek the size for it
202
    }
202
	}
203
203
204
    /**
204
	/**
205
         * testGetTopicExpressionProperty
205
	 * testGetTopicExpressionProperty
206
         * 
206
	 * 
207
         * @throws Exception
207
	 * @throws Exception
208
         */
208
	 */
209
    public void testGetTopicExpressionProperty() throws Exception
209
	public void testGetTopicExpressionProperty() throws Exception
210
    {
210
	{
211
	// TODO Get the DocumentRoot, Capability
211
		// TODO Get the DocumentRoot, Capability
212
	/*
212
		/*
213
         * DocumentRoot root_1 = null; Capability capability_1 = null;
213
		 * DocumentRoot root_1 = null; Capability capability_1 = null;
214
         * 
214
		 * 
215
         * PropertyMetaDataDescriptor metadataDescriptor_1 = new
215
		 * PropertyMetaDataDescriptor metadataDescriptor_1 = new
216
         * PropertyMetaDataDescriptor(root_1, capability_1);
216
		 * PropertyMetaDataDescriptor(root_1, capability_1); // For one file it
217
         *  // For one file it should be null PropertyType topicExpression_1 =
217
		 * should be null PropertyType topicExpression_1 =
218
         * metadataDescriptor_1.getTopicExpressionProperty();
218
		 * metadataDescriptor_1.getTopicExpressionProperty();
219
         * assertNull(topicExpression_1);
219
		 * assertNull(topicExpression_1); // TODO Get the DocumentRoot,
220
         *  // TODO Get the DocumentRoot, Capability DocumentRoot root_2 = null;
220
		 * Capability DocumentRoot root_2 = null; Capability capability_2 =
221
         * Capability capability_2 = null;
221
		 * null;
222
         * 
222
		 * 
223
         * PropertyMetaDataDescriptor metadataDescriptor_2 = new
223
		 * PropertyMetaDataDescriptor metadataDescriptor_2 = new
224
         * PropertyMetaDataDescriptor(root_2, capability_2);
224
		 * PropertyMetaDataDescriptor(root_2, capability_2); // For another file
225
         *  // For another file it should not be null PropertyType
225
		 * it should not be null PropertyType topicExpression_2 =
226
         * topicExpression_2 =
226
		 * metadataDescriptor_2.getTopicExpressionProperty();
227
         * metadataDescriptor_2.getTopicExpressionProperty();
227
		 * assertNotNull(topicExpression_2);
228
         * assertNotNull(topicExpression_2);
228
		 */
229
         */
229
	}
230
    }
230
231
231
	/**
232
    /**
232
	 * testGetTopicspaces
233
         * testGetTopicspaces
233
	 * 
234
         * 
234
	 * @throws Exception
235
         * @throws Exception
235
	 */
236
         */
236
	public void testGetTopicspaces() throws Exception
237
    public void testGetTopicspaces() throws Exception
237
	{
238
    {
238
		// We are already doing the same test in
239
	// We are already doing the same test in
239
		// MetaDataDescriptor2TopicSpaceTest
240
        // MetaDataDescriptor2TopicSpaceTest
240
	}
241
    }
241
242
242
	/**
243
    /**
243
	 * testSaveTopicspaces
244
         * testSaveTopicspaces
244
	 * 
245
         * 
245
	 * @throws Exception
246
         * @throws Exception
246
	 */
247
         */
247
	public void testSaveTopicspaces() throws Exception
248
    public void testSaveTopicspaces() throws Exception
248
	{
249
    {
249
		// We are already doing the same test in
250
	// We are already doing the same test in
250
		// TopicSpace2MetaDataDescriptorTest
251
        // TopicSpace2MetaDataDescriptorTest
251
	}
252
    }
253
252
254
}
253
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/CapUtilsTest.java (-220 / +222 lines)
Lines 31-264 Link Here
31
 */
31
 */
32
public class CapUtilsTest extends UtilsCapabilityTestModel
32
public class CapUtilsTest extends UtilsCapabilityTestModel
33
{
33
{
34
    /**
34
	/**
35
         * Constructor for CapUtilsTest.
35
	 * Constructor for CapUtilsTest.
36
         * 
36
	 * 
37
         * @param name
37
	 * @param name
38
         */
38
	 */
39
    public CapUtilsTest(String name)
39
	public CapUtilsTest(String name)
40
    {
40
	{
41
	super(name);
41
		super(name);
42
    }
42
	}
43
43
44
    /**
44
	/**
45
         * Returns the JUnit test suite that implements the <b>CapUtilsTest</b>
45
	 * Returns the JUnit test suite that implements the <b>CapUtilsTest</b>
46
         * definition.
46
	 * definition.
47
         */
47
	 */
48
    public static Test suite()
48
	public static Test suite()
49
    {
49
	{
50
	HyadesTestSuite capUtilsTest = new HyadesTestSuite("CapUtilsTest");
50
		HyadesTestSuite capUtilsTest = new HyadesTestSuite("CapUtilsTest");
51
	capUtilsTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
51
		capUtilsTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
52
		"EA3D854DD553CFED15CFD1E017F111DB");
52
				"EA3D854DD553CFED15CFD1E017F111DB");
53
53
54
	capUtilsTest.addTest(new CapUtilsTest("testGetMinOccurs"));
54
		capUtilsTest.addTest(new CapUtilsTest("testGetMinOccurs"));
55
	capUtilsTest.addTest(new CapUtilsTest("testGetMaxOccurs"));
55
		capUtilsTest.addTest(new CapUtilsTest("testGetMaxOccurs"));
56
	capUtilsTest.addTest(new CapUtilsTest("testGetInstancesOfProperty"));
56
		capUtilsTest.addTest(new CapUtilsTest("testGetInstancesOfProperty"));
57
	capUtilsTest.addTest(new CapUtilsTest("testGetInstancesOfOperation"));
57
		capUtilsTest.addTest(new CapUtilsTest("testGetInstancesOfOperation"));
58
	capUtilsTest.addTest(new CapUtilsTest("testGetInstancesOfParameter"));
58
		capUtilsTest.addTest(new CapUtilsTest("testGetInstancesOfParameter"));
59
	capUtilsTest.addTest(new CapUtilsTest("testValidateJavaIdentifier"));
59
		capUtilsTest.addTest(new CapUtilsTest("testValidateJavaIdentifier"));
60
	capUtilsTest.addTest(new CapUtilsTest("testGetName"));
60
		capUtilsTest.addTest(new CapUtilsTest("testGetName"));
61
	capUtilsTest.addTest(new CapUtilsTest("testIsOperationNameConflicted"));
61
		capUtilsTest.addTest(new CapUtilsTest("testIsOperationNameConflicted"));
62
	
62
63
	return capUtilsTest;
63
		return capUtilsTest;
64
    }
64
	}
65
65
66
    /**
66
	/**
67
         * @see junit.framework.TestCase#setUp()
67
	 * @see junit.framework.TestCase#setUp()
68
         */
68
	 */
69
    protected void setUp() throws Exception
69
	protected void setUp() throws Exception
70
    {
70
	{
71
	super.setUp();
71
		super.setUp();
72
    }
72
	}
73
73
74
    /**
74
	/**
75
         * @see junit.framework.TestCase#tearDown()
75
	 * @see junit.framework.TestCase#tearDown()
76
         */
76
	 */
77
    protected void tearDown() throws Exception
77
	protected void tearDown() throws Exception
78
    {
78
	{
79
    }
79
	}
80
80
81
    /**
81
	/**
82
         * testGetMinOccurs
82
	 * testGetMinOccurs
83
         * 
83
	 * 
84
         * @throws Exception
84
	 * @throws Exception
85
         */
85
	 */
86
    public void testGetMinOccurs() throws Exception
86
	public void testGetMinOccurs() throws Exception
87
    {
87
	{
88
	List properties = capabilityDomain.getCapability().getProperties();
88
		List properties = capabilityDomain.getCapability().getProperties();
89
	assertNotNull(properties);
89
		assertNotNull(properties);
90
	assertEquals(PROPERTY_NAMES.length, properties.size());
90
		assertEquals(PROPERTY_NAMES.length, properties.size());
91
	for (int i = 0; i < properties.size(); i++)
91
		for (int i = 0; i < properties.size(); i++)
92
	{
92
		{
93
	    Object object = properties.get(i);
93
			Object object = properties.get(i);
94
	    assertNotNull(object);
94
			assertNotNull(object);
95
	    assertTrue(object instanceof Property);
95
			assertTrue(object instanceof Property);
96
	    Property property = (Property) object;
96
			Property property = (Property) object;
97
	    XSDElementDeclaration element = property.getElement();
97
			XSDElementDeclaration element = property.getElement();
98
	    assertNotNull(element);
98
			assertNotNull(element);
99
	    int minoccurs = CapUtils.getMinOccurs(resourcePropertyElement,
99
			int minoccurs = CapUtils.getMinOccurs(resourcePropertyElement,
100
		    element);
100
					element);
101
	    assertEquals(MIN_OCCURS[i], minoccurs);
101
			assertEquals(MIN_OCCURS[i], minoccurs);
102
	}
102
		}
103
    }
103
	}
104
104
105
    /**
105
	/**
106
         * testGetMaxOccurs
106
	 * testGetMaxOccurs
107
         * 
107
	 * 
108
         * @throws Exception
108
	 * @throws Exception
109
         */
109
	 */
110
    public void testGetMaxOccurs() throws Exception
110
	public void testGetMaxOccurs() throws Exception
111
    {
111
	{
112
	List properties = capabilityDomain.getCapability().getProperties();
112
		List properties = capabilityDomain.getCapability().getProperties();
113
	assertNotNull(properties);
113
		assertNotNull(properties);
114
	assertEquals(PROPERTY_NAMES.length, properties.size());
114
		assertEquals(PROPERTY_NAMES.length, properties.size());
115
	for (int i = 0; i < properties.size(); i++)
115
		for (int i = 0; i < properties.size(); i++)
116
	{
116
		{
117
	    Object object = properties.get(i);
117
			Object object = properties.get(i);
118
	    assertNotNull(object);
118
			assertNotNull(object);
119
	    assertTrue(object instanceof Property);
119
			assertTrue(object instanceof Property);
120
	    Property property = (Property) object;
120
			Property property = (Property) object;
121
	    XSDElementDeclaration element = property.getElement();
121
			XSDElementDeclaration element = property.getElement();
122
	    assertNotNull(element);
122
			assertNotNull(element);
123
	    int maxoccurs = CapUtils.getMaxOccurs(resourcePropertyElement,
123
			int maxoccurs = CapUtils.getMaxOccurs(resourcePropertyElement,
124
		    element);
124
					element);
125
	    assertEquals(MAX_OCCURS[i], maxoccurs);
125
			assertEquals(MAX_OCCURS[i], maxoccurs);
126
	}
126
		}
127
    }
127
	}
128
128
129
    /**
129
	/**
130
         * testGetInstancesOfProperty
130
	 * testGetInstancesOfProperty
131
         * 
131
	 * 
132
         * @throws Exception
132
	 * @throws Exception
133
         */
133
	 */
134
    public void testGetInstancesOfProperty() throws Exception
134
	public void testGetInstancesOfProperty() throws Exception
135
    {
135
	{
136
	List properties = capabilityDomain.getCapability().getProperties();
136
		List properties = capabilityDomain.getCapability().getProperties();
137
	assertNotNull(properties);
137
		assertNotNull(properties);
138
	assertEquals(PROPERTY_NAMES.length, properties.size());
138
		assertEquals(PROPERTY_NAMES.length, properties.size());
139
	for (int i = 0; i < properties.size(); i++)
139
		for (int i = 0; i < properties.size(); i++)
140
	{
140
		{
141
	    Object object = properties.get(i);
141
			Object object = properties.get(i);
142
	    assertNotNull(object);
142
			assertNotNull(object);
143
	    assertTrue(object instanceof Property);
143
			assertTrue(object instanceof Property);
144
	    Property property = (Property) object;
144
			Property property = (Property) object;
145
	    XSDElementDeclaration element = property.getElement();
145
			XSDElementDeclaration element = property.getElement();
146
	    String propName = XsdUtils.getName(element);
146
			String propName = XsdUtils.getName(element);
147
	    Capability model = capabilityDomain.getCapability();
147
			Capability model = capabilityDomain.getCapability();
148
	    int instances = CapUtils.getInstancesOfProperty(model, propName);
148
			int instances = CapUtils.getInstancesOfProperty(model, propName);
149
	    assertEquals(1, instances);
149
			assertEquals(1, instances);
150
	}
150
		}
151
151
152
	String unknownProperty = "UNKNOWN";
152
		String unknownProperty = "UNKNOWN";
153
	Capability model = capabilityDomain.getCapability();
153
		Capability model = capabilityDomain.getCapability();
154
	int instances = CapUtils.getInstancesOfProperty(model, unknownProperty);
154
		int instances = CapUtils.getInstancesOfProperty(model, unknownProperty);
155
	assertEquals(0, instances);
155
		assertEquals(0, instances);
156
    }
156
	}
157
157
158
    /**
158
	/**
159
         * testGetInstancesOfOperation
159
	 * testGetInstancesOfOperation
160
         * 
160
	 * 
161
         * @throws Exception
161
	 * @throws Exception
162
         */
162
	 */
163
    public void testGetInstancesOfOperation() throws Exception
163
	public void testGetInstancesOfOperation() throws Exception
164
    {
164
	{
165
	List operations = capabilityDomain.getCapability().getOperations();
165
		List operations = capabilityDomain.getCapability().getOperations();
166
	assertNotNull(operations);
166
		assertNotNull(operations);
167
	assertEquals(OPERATION_NAMES.length, operations.size());
167
		assertEquals(OPERATION_NAMES.length, operations.size());
168
	for (int i = 0; i < operations.size(); i++)
168
		for (int i = 0; i < operations.size(); i++)
169
	{
169
		{
170
	    Object object = operations.get(i);
170
			Object object = operations.get(i);
171
	    assertNotNull(object);
171
			assertNotNull(object);
172
	    assertTrue(object instanceof Operation);
172
			assertTrue(object instanceof Operation);
173
	    Operation operation = (Operation) object;
173
			Operation operation = (Operation) object;
174
	    String opName = WsdlUtils.getOperationName(operation);
174
			String opName = WsdlUtils.getOperationName(operation);
175
	    Capability model = capabilityDomain.getCapability();
175
			Capability model = capabilityDomain.getCapability();
176
	    int instances = CapUtils.getInstancesOfOperation(model, opName);
176
			int instances = CapUtils.getInstancesOfOperation(model, opName);
177
	    assertEquals(1, instances);
177
			assertEquals(1, instances);
178
	}
178
		}
179
179
180
	String unknownOperation = "UNKNOWN";
180
		String unknownOperation = "UNKNOWN";
181
	Capability model = capabilityDomain.getCapability();
181
		Capability model = capabilityDomain.getCapability();
182
	int instances = CapUtils.getInstancesOfOperation(model,
182
		int instances = CapUtils.getInstancesOfOperation(model,
183
		unknownOperation);
183
				unknownOperation);
184
	assertEquals(0, instances);
184
		assertEquals(0, instances);
185
    }
185
	}
186
186
187
    /**
187
	/**
188
         * testGetInstancesOfParameter
188
	 * testGetInstancesOfParameter
189
         * 
189
	 * 
190
         * @throws Exception
190
	 * @throws Exception
191
         */
191
	 */
192
    public void testGetInstancesOfParameter() throws Exception
192
	public void testGetInstancesOfParameter() throws Exception
193
    {
193
	{
194
	List operations = capabilityDomain.getCapability().getOperations();
194
		List operations = capabilityDomain.getCapability().getOperations();
195
	assertNotNull(operations);
195
		assertNotNull(operations);
196
	assertEquals(OPERATION_NAMES.length, operations.size());
196
		assertEquals(OPERATION_NAMES.length, operations.size());
197
197
198
	Operation startServer = (Operation) operations.get(0);
198
		Operation startServer = (Operation) operations.get(0);
199
	int instances = CapUtils.getInstancesOfParameter(startServer,
199
		int instances = CapUtils.getInstancesOfParameter(startServer,
200
		"ServerName");
200
				"ServerName");
201
	assertEquals(0, instances);
201
		assertEquals(0, instances);
202
202
203
	Operation startApplication = (Operation) operations.get(2);
203
		Operation startApplication = (Operation) operations.get(2);
204
	instances = CapUtils.getInstancesOfParameter(startApplication,
204
		instances = CapUtils.getInstancesOfParameter(startApplication,
205
		"appName");
205
				"appName");
206
	assertEquals(1, instances);
206
		assertEquals(1, instances);
207
    }
207
	}
208
208
209
    /**
209
	/**
210
         * testValidateJavaIdentifier
210
	 * testValidateJavaIdentifier
211
         * 
211
	 * 
212
         * @throws Exception
212
	 * @throws Exception
213
         */
213
	 */
214
    public void testValidateJavaIdentifier() throws Exception
214
	public void testValidateJavaIdentifier() throws Exception
215
    {
215
	{
216
	String name = "";
216
		String name = "";
217
	String validate = CapUtils.validateJavaIdentifier(name);
217
		String validate = CapUtils.validateJavaIdentifier(name);
218
	assertTrue(validate.indexOf("Empty name") != -1);
218
		assertTrue(validate.indexOf("Empty name") != -1);
219
219
220
	name = "2home";
220
		name = "2home";
221
	validate = CapUtils.validateJavaIdentifier(name);
221
		validate = CapUtils.validateJavaIdentifier(name);
222
	assertTrue(validate.indexOf("Invalid name:") != -1);
222
		assertTrue(validate.indexOf("Invalid name:") != -1);
223
223
224
	name = "if";
224
		name = "if";
225
	validate = CapUtils.validateJavaIdentifier(name);
225
		validate = CapUtils.validateJavaIdentifier(name);
226
	assertTrue(validate.indexOf("Java keyword") != -1);
226
		assertTrue(validate.indexOf("Java keyword") != -1);
227
227
228
	name = "home";
228
		name = "home";
229
	validate = CapUtils.validateJavaIdentifier(name);
229
		validate = CapUtils.validateJavaIdentifier(name);
230
	assertNull(validate);
230
		assertNull(validate);
231
    }
231
	}
232
232
233
    /**
233
	/**
234
         * testGetName
234
	 * testGetName
235
         * 
235
	 * 
236
         * @throws Exception
236
	 * @throws Exception
237
         */
237
	 */
238
    public void testGetName() throws Exception
238
	public void testGetName() throws Exception
239
    {
239
	{
240
	List properties = capabilityDomain.getCapability().getProperties();
240
		List properties = capabilityDomain.getCapability().getProperties();
241
	assertNotNull(properties);
241
		assertNotNull(properties);
242
	assertEquals(PROPERTY_NAMES.length, properties.size());
242
		assertEquals(PROPERTY_NAMES.length, properties.size());
243
	for (int i = 0; i < properties.size(); i++)
243
		for (int i = 0; i < properties.size(); i++)
244
	{
244
		{
245
	    Object object = properties.get(i);
245
			Object object = properties.get(i);
246
	    assertNotNull(object);
246
			assertNotNull(object);
247
	    assertTrue(object instanceof Property);
247
			assertTrue(object instanceof Property);
248
	    Property property = (Property) object;
248
			Property property = (Property) object;
249
	    String propName = CapUtils.getName(property);
249
			String propName = CapUtils.getName(property);
250
	    assertEquals(PROPERTY_NAMES[i], propName);
250
			assertEquals(PROPERTY_NAMES[i], propName);
251
		}
251
	}
252
	}
252
    }
253
253
254
	/**
254
	/**
255
	 * testIsOperationNameConflicted
255
	 * testIsOperationNameConflicted
256
	 * 
256
	 * @throws Exception
257
	 * @throws Exception
257
	 */
258
	 */
258
	public void testIsOperationNameConflicted() throws Exception {
259
	public void testIsOperationNameConflicted() throws Exception
260
	{
259
		boolean conflicted = CapUtils.isOperationNameConflicted("shutdown");
261
		boolean conflicted = CapUtils.isOperationNameConflicted("shutdown");
260
		assertTrue(conflicted);
262
		assertTrue(conflicted);
261
		
263
262
		conflicted = CapUtils.isOperationNameConflicted("foo");
264
		conflicted = CapUtils.isOperationNameConflicted("foo");
263
		assertFalse(conflicted);
265
		assertFalse(conflicted);
264
	}
266
	}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/MetaDataDescriptor2TopicSpaceTest.java (-104 / +105 lines)
Lines 28-136 Link Here
28
 */
28
 */
29
public class MetaDataDescriptor2TopicSpaceTest extends UtilsCapabilityTestModel
29
public class MetaDataDescriptor2TopicSpaceTest extends UtilsCapabilityTestModel
30
{
30
{
31
    /**
31
	/**
32
         * Constructor for MetaDataDescriptor2TopicSpaceTest.
32
	 * Constructor for MetaDataDescriptor2TopicSpaceTest.
33
         * 
33
	 * 
34
         * @param name
34
	 * @param name
35
         */
35
	 */
36
    public MetaDataDescriptor2TopicSpaceTest(String name)
36
	public MetaDataDescriptor2TopicSpaceTest(String name)
37
    {
37
	{
38
	super(name);
38
		super(name);
39
    }
39
	}
40
40
41
    /**
41
	/**
42
         * Returns the JUnit test suite that implements the
42
	 * Returns the JUnit test suite that implements the
43
         * <b>MetaDataDescriptor2TopicSpaceTest</b> definition.
43
	 * <b>MetaDataDescriptor2TopicSpaceTest</b> definition.
44
         */
44
	 */
45
    public static Test suite()
45
	public static Test suite()
46
    {
46
	{
47
	HyadesTestSuite metaDataDescriptor2TopicSpaceTest = new HyadesTestSuite(
47
		HyadesTestSuite metaDataDescriptor2TopicSpaceTest = new HyadesTestSuite(
48
		"MetaDataDescriptor2TopicSpaceTest");
48
				"MetaDataDescriptor2TopicSpaceTest");
49
	metaDataDescriptor2TopicSpaceTest.setArbiter(
49
		metaDataDescriptor2TopicSpaceTest.setArbiter(
50
		DefaultTestArbiter.INSTANCE).setId(
50
				DefaultTestArbiter.INSTANCE).setId(
51
		"C254CB80544979D7DBCC0D6042F711DB");
51
				"C254CB80544979D7DBCC0D6042F711DB");
52
52
53
	metaDataDescriptor2TopicSpaceTest
53
		metaDataDescriptor2TopicSpaceTest
54
		.addTest(new MetaDataDescriptor2TopicSpaceTest(
54
				.addTest(new MetaDataDescriptor2TopicSpaceTest(
55
			"testGetTopicspaces"));
55
						"testGetTopicspaces"));
56
56
57
	return metaDataDescriptor2TopicSpaceTest;
57
		return metaDataDescriptor2TopicSpaceTest;
58
    }
58
	}
59
59
60
    /**
60
	/**
61
         * @see junit.framework.TestCase#setUp()
61
	 * @see junit.framework.TestCase#setUp()
62
         */
62
	 */
63
    protected void setUp() throws Exception
63
	protected void setUp() throws Exception
64
    {
64
	{
65
	super.setUp();
65
		super.setUp();
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * @see junit.framework.TestCase#tearDown()
69
	 * @see junit.framework.TestCase#tearDown()
70
         */
70
	 */
71
    protected void tearDown() throws Exception
71
	protected void tearDown() throws Exception
72
    {
72
	{
73
    }
73
	}
74
74
75
    /**
75
	/**
76
         * testGetTopicspaces
76
	 * testGetTopicspaces
77
         * 
77
	 * 
78
         * @throws Exception
78
	 * @throws Exception
79
         */
79
	 */
80
    public void testGetTopicspaces() throws Exception
80
	public void testGetTopicspaces() throws Exception
81
    {
81
	{
82
	List topicSpaces = metaDataDescriptor.getTopicSpaces();
82
		metaDataDescriptor.loadTopicSpaces();
83
83
		List topicSpaces = capability.getTopicSpaces();
84
	assertNotNull(topicSpaces);
84
85
	assertEquals(2, topicSpaces.size());
85
		assertNotNull(topicSpaces);
86
86
		assertEquals(2, topicSpaces.size());
87
	verifyStartTopicNamespace(topicSpaces);
87
88
88
		verifyStartTopicNamespace(topicSpaces);
89
	verifyStopTopicNamespace(topicSpaces);
89
90
    }
90
		verifyStopTopicNamespace(topicSpaces);
91
91
	}
92
    private void verifyStartTopicNamespace(List topicSpaces)
92
93
    {
93
	private void verifyStartTopicNamespace(List topicSpaces)
94
	TopicSpace startTopicSpace = (TopicSpace) topicSpaces.get(0);
94
	{
95
	assertEquals("http://start.org", startTopicSpace.getNamespace());
95
		TopicSpace startTopicSpace = (TopicSpace) topicSpaces.get(0);
96
96
		assertEquals("http://start.org", startTopicSpace.getNamespace());
97
	List startTopicSpaceRootTopicsList = startTopicSpace.getRootTopics();
97
98
	assertNotNull(startTopicSpaceRootTopicsList);
98
		List startTopicSpaceRootTopicsList = startTopicSpace.getRootTopics();
99
	assertEquals(1, startTopicSpaceRootTopicsList.size());
99
		assertNotNull(startTopicSpaceRootTopicsList);
100
100
		assertEquals(1, startTopicSpaceRootTopicsList.size());
101
	Topic startServerTopic = (Topic) startTopicSpaceRootTopicsList.get(0);
101
102
	assertNull(startServerTopic.getParent());
102
		Topic startServerTopic = (Topic) startTopicSpaceRootTopicsList.get(0);
103
	assertEquals("StartServer", startServerTopic.getName());
103
		assertNull(startServerTopic.getParent());
104
104
		assertEquals("StartServer", startServerTopic.getName());
105
	List startServerTopicChildList = startServerTopic.getChildren();
105
106
	assertNotNull(startServerTopicChildList);
106
		List startServerTopicChildList = startServerTopic.getChildren();
107
	assertEquals(1, startServerTopicChildList.size());
107
		assertNotNull(startServerTopicChildList);
108
108
		assertEquals(1, startServerTopicChildList.size());
109
	Topic startDataResourceTopic = (Topic) startServerTopicChildList.get(0);
109
110
	assertEquals(startServerTopic, startDataResourceTopic.getParent());
110
		Topic startDataResourceTopic = (Topic) startServerTopicChildList.get(0);
111
	assertEquals("StartDataResource", startDataResourceTopic.getName());
111
		assertEquals(startServerTopic, startDataResourceTopic.getParent());
112
    }
112
		assertEquals("StartDataResource", startDataResourceTopic.getName());
113
113
	}
114
    private void verifyStopTopicNamespace(List topicSpaces)
114
115
    {
115
	private void verifyStopTopicNamespace(List topicSpaces)
116
	TopicSpace stopTopicSpace = (TopicSpace) topicSpaces.get(1);
116
	{
117
	assertEquals("http://stop.org", stopTopicSpace.getNamespace());
117
		TopicSpace stopTopicSpace = (TopicSpace) topicSpaces.get(1);
118
118
		assertEquals("http://stop.org", stopTopicSpace.getNamespace());
119
	List stopTopicSpaceRootTopicsList = stopTopicSpace.getRootTopics();
119
120
	assertNotNull(stopTopicSpaceRootTopicsList);
120
		List stopTopicSpaceRootTopicsList = stopTopicSpace.getRootTopics();
121
	assertEquals(1, stopTopicSpaceRootTopicsList.size());
121
		assertNotNull(stopTopicSpaceRootTopicsList);
122
122
		assertEquals(1, stopTopicSpaceRootTopicsList.size());
123
	Topic stopServerTopic = (Topic) stopTopicSpaceRootTopicsList.get(0);
123
124
	assertNull(stopServerTopic.getParent());
124
		Topic stopServerTopic = (Topic) stopTopicSpaceRootTopicsList.get(0);
125
	assertEquals("StopServer", stopServerTopic.getName());
125
		assertNull(stopServerTopic.getParent());
126
126
		assertEquals("StopServer", stopServerTopic.getName());
127
	List stopServerTopicChildList = stopServerTopic.getChildren();
127
128
	assertNotNull(stopServerTopicChildList);
128
		List stopServerTopicChildList = stopServerTopic.getChildren();
129
	assertEquals(1, stopServerTopicChildList.size());
129
		assertNotNull(stopServerTopicChildList);
130
130
		assertEquals(1, stopServerTopicChildList.size());
131
	Topic stopDataResourceTopic = (Topic) stopServerTopicChildList.get(0);
131
132
	assertEquals(stopServerTopic, stopDataResourceTopic.getParent());
132
		Topic stopDataResourceTopic = (Topic) stopServerTopicChildList.get(0);
133
	assertEquals("StopDataResource", stopDataResourceTopic.getName());
133
		assertEquals(stopServerTopic, stopDataResourceTopic.getParent());
134
    }
134
		assertEquals("StopDataResource", stopDataResourceTopic.getName());
135
	}
135
136
136
}
137
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/EclipseUtilsTest.java (-60 / +60 lines)
Lines 24-88 Link Here
24
 */
24
 */
25
public class EclipseUtilsTest extends HyadesTestCase
25
public class EclipseUtilsTest extends HyadesTestCase
26
{
26
{
27
    /**
27
	/**
28
         * Constructor for EclipseUtilsTest.
28
	 * Constructor for EclipseUtilsTest.
29
         * 
29
	 * 
30
         * @param name
30
	 * @param name
31
         */
31
	 */
32
    public EclipseUtilsTest(String name)
32
	public EclipseUtilsTest(String name)
33
    {
33
	{
34
	super(name);
34
		super(name);
35
    }
35
	}
36
36
37
    /**
37
	/**
38
         * Returns the JUnit test suite that implements the <b>EclipseUtilsTest</b>
38
	 * Returns the JUnit test suite that implements the <b>EclipseUtilsTest</b>
39
         * definition.
39
	 * definition.
40
         */
40
	 */
41
    public static Test suite()
41
	public static Test suite()
42
    {
42
	{
43
	HyadesTestSuite eclipseUtilsTest = new HyadesTestSuite(
43
		HyadesTestSuite eclipseUtilsTest = new HyadesTestSuite(
44
		"EclipseUtilsTest");
44
				"EclipseUtilsTest");
45
	eclipseUtilsTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
45
		eclipseUtilsTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
46
		"C254CB80544979D7BE50E71042F711DB");
46
				"C254CB80544979D7BE50E71042F711DB");
47
47
48
	eclipseUtilsTest.addTest(new EclipseUtilsTest("testGetRelativePath"));
48
		eclipseUtilsTest.addTest(new EclipseUtilsTest("testGetRelativePath"));
49
	eclipseUtilsTest.addTest(new EclipseUtilsTest("testReplaceAll"));
49
		eclipseUtilsTest.addTest(new EclipseUtilsTest("testReplaceAll"));
50
50
51
	return eclipseUtilsTest;
51
		return eclipseUtilsTest;
52
    }
52
	}
53
53
54
    /**
54
	/**
55
         * @see junit.framework.TestCase#setUp()
55
	 * @see junit.framework.TestCase#setUp()
56
         */
56
	 */
57
    protected void setUp() throws Exception
57
	protected void setUp() throws Exception
58
    {
58
	{
59
    }
59
	}
60
60
61
    /**
61
	/**
62
         * @see junit.framework.TestCase#tearDown()
62
	 * @see junit.framework.TestCase#tearDown()
63
         */
63
	 */
64
    protected void tearDown() throws Exception
64
	protected void tearDown() throws Exception
65
    {
65
	{
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * testGetRelativePath
69
	 * testGetRelativePath
70
         * 
70
	 * 
71
         * @throws Exception
71
	 * @throws Exception
72
         */
72
	 */
73
    public void testGetRelativePath() throws Exception
73
	public void testGetRelativePath() throws Exception
74
    {
74
	{
75
	// Enter your code here
75
		// Enter your code here
76
    }
76
	}
77
77
78
    /**
78
	/**
79
         * testReplaceAll
79
	 * testReplaceAll
80
         * 
80
	 * 
81
         * @throws Exception
81
	 * @throws Exception
82
         */
82
	 */
83
    public void testReplaceAll() throws Exception
83
	public void testReplaceAll() throws Exception
84
    {
84
	{
85
	// Enter your code here
85
		// Enter your code here
86
    }
86
	}
87
87
88
}
88
}
(-)src/org/eclipse/tptp/wsdm/tooling/test/util/AllUtilTest.java (-59 / +59 lines)
Lines 24-87 Link Here
24
 */
24
 */
25
public class AllUtilTest extends HyadesTestCase
25
public class AllUtilTest extends HyadesTestCase
26
{
26
{
27
    /**
27
	/**
28
         * Constructor for AllUtilTest.
28
	 * Constructor for AllUtilTest.
29
         * 
29
	 * 
30
         * @param name
30
	 * @param name
31
         */
31
	 */
32
    public AllUtilTest(String name)
32
	public AllUtilTest(String name)
33
    {
33
	{
34
	super(name);
34
		super(name);
35
    }
35
	}
36
36
37
    /**
37
	/**
38
         * Returns the JUnit test suite that implements the <b>AllUtilTest</b>
38
	 * Returns the JUnit test suite that implements the <b>AllUtilTest</b>
39
         * definition.
39
	 * definition.
40
         */
40
	 */
41
    public static Test suite()
41
	public static Test suite()
42
    {
42
	{
43
	HyadesTestSuite allUtilTest = new HyadesTestSuite("AllUtilTest");
43
		HyadesTestSuite allUtilTest = new HyadesTestSuite("AllUtilTest");
44
	allUtilTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
44
		allUtilTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
45
		"EFF2985B4634B8E3F213E31017E911DB");
45
				"EFF2985B4634B8E3F213E31017E911DB");
46
46
47
	allUtilTest.addTest(HyadesJUnitRunner.getTest(CapUtilsTest.class));
47
		allUtilTest.addTest(HyadesJUnitRunner.getTest(CapUtilsTest.class));
48
48
49
	allUtilTest.addTest(HyadesJUnitRunner
49
		allUtilTest.addTest(HyadesJUnitRunner
50
		.getTest(Definition2CapabilityTest.class));
50
				.getTest(Definition2CapabilityTest.class));
51
51
52
	allUtilTest.addTest(HyadesJUnitRunner.getTest(EclipseUtilsTest.class));
52
		allUtilTest.addTest(HyadesJUnitRunner.getTest(EclipseUtilsTest.class));
53
53
54
	allUtilTest.addTest(HyadesJUnitRunner
54
		allUtilTest.addTest(HyadesJUnitRunner
55
		.getTest(MetaDataDescriptor2TopicSpaceTest.class));
55
				.getTest(MetaDataDescriptor2TopicSpaceTest.class));
56
56
57
	allUtilTest.addTest(HyadesJUnitRunner.getTest(MetaDataUtilsTest.class));
57
		allUtilTest.addTest(HyadesJUnitRunner.getTest(MetaDataUtilsTest.class));
58
58
59
	allUtilTest.addTest(HyadesJUnitRunner
59
		allUtilTest.addTest(HyadesJUnitRunner
60
		.getTest(PropertyMetaDataDescriptorTest.class));
60
				.getTest(PropertyMetaDataDescriptorTest.class));
61
61
62
	allUtilTest.addTest(HyadesJUnitRunner
62
		allUtilTest.addTest(HyadesJUnitRunner
63
		.getTest(TopicSpace2MetaDataDescriptorTest.class));
63
				.getTest(TopicSpace2MetaDataDescriptorTest.class));
64
64
65
	allUtilTest.addTest(HyadesJUnitRunner.getTest(ValidationTest.class));
65
		allUtilTest.addTest(HyadesJUnitRunner.getTest(ValidationTest.class));
66
66
67
	allUtilTest.addTest(HyadesJUnitRunner.getTest(WSDLUtilsTest.class));
67
		allUtilTest.addTest(HyadesJUnitRunner.getTest(WSDLUtilsTest.class));
68
68
69
	allUtilTest.addTest(HyadesJUnitRunner.getTest(XSDUtilsTest.class));
69
		allUtilTest.addTest(HyadesJUnitRunner.getTest(XSDUtilsTest.class));
70
	return allUtilTest;
70
		return allUtilTest;
71
    }
71
	}
72
72
73
    /**
73
	/**
74
         * @see junit.framework.TestCase#setUp()
74
	 * @see junit.framework.TestCase#setUp()
75
         */
75
	 */
76
    protected void setUp() throws Exception
76
	protected void setUp() throws Exception
77
    {
77
	{
78
    }
78
	}
79
79
80
    /**
80
	/**
81
         * @see junit.framework.TestCase#tearDown()
81
	 * @see junit.framework.TestCase#tearDown()
82
         */
82
	 */
83
    protected void tearDown() throws Exception
83
	protected void tearDown() throws Exception
84
    {
84
	{
85
    }
85
	}
86
86
87
}
87
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/test/Activator.java (-42 / +42 lines)
Lines 20-68 Link Here
20
public class Activator extends Plugin
20
public class Activator extends Plugin
21
{
21
{
22
22
23
    // The plug-in ID
23
	// The plug-in ID
24
    public static final String PLUGIN_ID = "org.eclipse.tptp.wsdm.tooling.editor.capability.test";
24
	public static final String PLUGIN_ID = "org.eclipse.tptp.wsdm.tooling.editor.capability.test";
25
25
26
    // The shared instance
26
	// The shared instance
27
    private static Activator plugin;
27
	private static Activator plugin;
28
28
29
    /**
29
	/**
30
         * The constructor
30
	 * The constructor
31
         */
31
	 */
32
    public Activator()
32
	public Activator()
33
    {
33
	{
34
	plugin = this;
34
		plugin = this;
35
    }
35
	}
36
36
37
    /*
37
	/*
38
         * (non-Javadoc)
38
	 * (non-Javadoc)
39
         * 
39
	 * 
40
         * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
40
	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
41
         */
41
	 */
42
    public void start(BundleContext context) throws Exception
42
	public void start(BundleContext context) throws Exception
43
    {
43
	{
44
	super.start(context);
44
		super.start(context);
45
    }
45
	}
46
46
47
    /*
47
	/*
48
         * (non-Javadoc)
48
	 * (non-Javadoc)
49
         * 
49
	 * 
50
         * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
50
	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
51
         */
51
	 */
52
    public void stop(BundleContext context) throws Exception
52
	public void stop(BundleContext context) throws Exception
53
    {
53
	{
54
	plugin = null;
54
		plugin = null;
55
	super.stop(context);
55
		super.stop(context);
56
    }
56
	}
57
57
58
    /**
58
	/**
59
         * Returns the shared instance
59
	 * Returns the shared instance
60
         * 
60
	 * 
61
         * @return the shared instance
61
	 * @return the shared instance
62
         */
62
	 */
63
    public static Activator getDefault()
63
	public static Activator getDefault()
64
    {
64
	{
65
	return plugin;
65
		return plugin;
66
    }
66
	}
67
67
68
}
68
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/ChangeOperationReturnTypeCommandTest.java (-71 / +71 lines)
Lines 32-108 Link Here
32
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/operation/command/ChangeOperationReturnTypeCommandTest.testsuite</i>.
32
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/operation/command/ChangeOperationReturnTypeCommandTest.testsuite</i>.
33
 */
33
 */
34
public class ChangeOperationReturnTypeCommandTest extends
34
public class ChangeOperationReturnTypeCommandTest extends
35
	OperationCommandTestModel
35
		OperationCommandTestModel
36
{
36
{
37
    /**
37
	/**
38
         * Constructor for ChangeOperationReturnTypeCommandTest.
38
	 * Constructor for ChangeOperationReturnTypeCommandTest.
39
         * 
39
	 * 
40
         * @param name
40
	 * @param name
41
         */
41
	 */
42
    public ChangeOperationReturnTypeCommandTest(String name)
42
	public ChangeOperationReturnTypeCommandTest(String name)
43
    {
43
	{
44
	super(name);
44
		super(name);
45
    }
45
	}
46
46
47
    /**
47
	/**
48
         * Returns the JUnit test suite that implements the
48
	 * Returns the JUnit test suite that implements the
49
         * <b>ChangeOperationReturnTypeCommandTest</b> definition.
49
	 * <b>ChangeOperationReturnTypeCommandTest</b> definition.
50
         */
50
	 */
51
    public static Test suite()
51
	public static Test suite()
52
    {
52
	{
53
	HyadesTestSuite changeOperationReturnTypeCommandTest = new HyadesTestSuite(
53
		HyadesTestSuite changeOperationReturnTypeCommandTest = new HyadesTestSuite(
54
		"ChangeOperationReturnTypeCommandTest");
54
				"ChangeOperationReturnTypeCommandTest");
55
	changeOperationReturnTypeCommandTest.setArbiter(
55
		changeOperationReturnTypeCommandTest.setArbiter(
56
		DefaultTestArbiter.INSTANCE).setId(
56
				DefaultTestArbiter.INSTANCE).setId(
57
		"C8E89291F2E4762C8F95A9C0100611DB");
57
				"C8E89291F2E4762C8F95A9C0100611DB");
58
58
59
	changeOperationReturnTypeCommandTest
59
		changeOperationReturnTypeCommandTest
60
		.addTest(new ChangeOperationReturnTypeCommandTest(
60
				.addTest(new ChangeOperationReturnTypeCommandTest(
61
			"testChangeOperationReturnType"));
61
						"testChangeOperationReturnType"));
62
62
63
	return changeOperationReturnTypeCommandTest;
63
		return changeOperationReturnTypeCommandTest;
64
    }
64
	}
65
65
66
    /**
66
	/**
67
         * @see junit.framework.TestCase#setUp()
67
	 * @see junit.framework.TestCase#setUp()
68
         */
68
	 */
69
    protected void setUp() throws Exception
69
	protected void setUp() throws Exception
70
    {
70
	{
71
	super.setUp();
71
		super.setUp();
72
    }
72
	}
73
73
74
    /**
74
	/**
75
         * @see junit.framework.TestCase#tearDown()
75
	 * @see junit.framework.TestCase#tearDown()
76
         */
76
	 */
77
    protected void tearDown() throws Exception
77
	protected void tearDown() throws Exception
78
    {
78
	{
79
    }
79
	}
80
80
81
    /**
81
	/**
82
         * testChangeOperationReturnType
82
	 * testChangeOperationReturnType
83
         * 
83
	 * 
84
         * @throws Exception
84
	 * @throws Exception
85
         */
85
	 */
86
    public void testChangeOperationReturnType() throws Exception
86
	public void testChangeOperationReturnType() throws Exception
87
    {
87
	{
88
	List opList = capability.getOperations();
88
		List opList = capability.getOperations();
89
	int totalOperations = opList.size();
89
		int totalOperations = opList.size();
90
	assertNotNull(opList);
90
		assertNotNull(opList);
91
	assertTrue(totalOperations > 0);
91
		assertTrue(totalOperations > 0);
92
	Object object = opList.get(0);
92
		Object object = opList.get(0);
93
	assertTrue(object instanceof Operation);
93
		assertTrue(object instanceof Operation);
94
	Operation operation = (Operation) object;
94
		Operation operation = (Operation) object;
95
	DataType intDataType = TestUtils.getDataType("int");
95
		DataType intDataType = TestUtils.getDataType("int");
96
	String newType = new String(intDataType.getTypeName());
96
		String newType = new String(intDataType.getTypeName());
97
97
98
	ChangeOperationReturnTypeCommand command = new ChangeOperationReturnTypeCommand(
98
		ChangeOperationReturnTypeCommand command = new ChangeOperationReturnTypeCommand(
99
		operation, intDataType);
99
				operation, intDataType);
100
	command.execute();
100
		command.execute();
101
101
102
	XSDElementDeclaration returnTypeDeclaration = WsdlUtils
102
		XSDElementDeclaration returnTypeDeclaration = WsdlUtils
103
		.getReturnTypeElement(operation);
103
				.getReturnTypeElement(operation);
104
	assertNotNull(returnTypeDeclaration);
104
		assertNotNull(returnTypeDeclaration);
105
	assertEquals(newType, XsdUtils.getType(returnTypeDeclaration));
105
		assertEquals(newType, XsdUtils.getType(returnTypeDeclaration));
106
    }
106
	}
107
107
108
}
108
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/AddOperationCommandTest.java (-63 / +63 lines)
Lines 26-93 Link Here
26
 */
26
 */
27
public class AddOperationCommandTest extends OperationCommandTestModel
27
public class AddOperationCommandTest extends OperationCommandTestModel
28
{
28
{
29
    /**
29
	/**
30
         * Constructor for AddOperationCommandTest.
30
	 * Constructor for AddOperationCommandTest.
31
         * 
31
	 * 
32
         * @param name
32
	 * @param name
33
         */
33
	 */
34
    public AddOperationCommandTest(String name)
34
	public AddOperationCommandTest(String name)
35
    {
35
	{
36
	super(name);
36
		super(name);
37
    }
37
	}
38
38
39
    /**
39
	/**
40
         * Returns the JUnit test suite that implements the
40
	 * Returns the JUnit test suite that implements the
41
         * <b>AddOperationCommandTest</b> definition.
41
	 * <b>AddOperationCommandTest</b> definition.
42
         */
42
	 */
43
    public static Test suite()
43
	public static Test suite()
44
    {
44
	{
45
	HyadesTestSuite addOperationCommandTest = new HyadesTestSuite(
45
		HyadesTestSuite addOperationCommandTest = new HyadesTestSuite(
46
		"AddOperationCommandTest");
46
				"AddOperationCommandTest");
47
	addOperationCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
47
		addOperationCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
48
		"C8E89291F2E4762CE5C63C20100011DB");
48
				"C8E89291F2E4762CE5C63C20100011DB");
49
49
50
	addOperationCommandTest.addTest(new AddOperationCommandTest(
50
		addOperationCommandTest.addTest(new AddOperationCommandTest(
51
		"testAddOperation"));
51
				"testAddOperation"));
52
52
53
	return addOperationCommandTest;
53
		return addOperationCommandTest;
54
    }
54
	}
55
55
56
    /**
56
	/**
57
         * @see junit.framework.TestCase#setUp()
57
	 * @see junit.framework.TestCase#setUp()
58
         */
58
	 */
59
    protected void setUp() throws Exception
59
	protected void setUp() throws Exception
60
    {
60
	{
61
	super.setUp();
61
		super.setUp();
62
    }
62
	}
63
63
64
    /**
64
	/**
65
         * @see junit.framework.TestCase#tearDown()
65
	 * @see junit.framework.TestCase#tearDown()
66
         */
66
	 */
67
    protected void tearDown() throws Exception
67
	protected void tearDown() throws Exception
68
    {
68
	{
69
    }
69
	}
70
70
71
    /**
71
	/**
72
         * testAddOperation
72
	 * testAddOperation
73
         * 
73
	 * 
74
         * @throws Exception
74
	 * @throws Exception
75
         */
75
	 */
76
    public void testAddOperation() throws Exception
76
	public void testAddOperation() throws Exception
77
    {
77
	{
78
	int totalOperations = WsdlUtils.getWSDLOperation(definition).length;
78
		int totalOperations = WsdlUtils.getWSDLOperation(definition).length;
79
	Operation newOperation = TestUtils.createNewOperation(definition);
79
		Operation newOperation = TestUtils.createNewOperation(definition);
80
	newOperation.setName("foo");
80
		newOperation.setName("foo");
81
	AddOperationCommand command = new AddOperationCommand(capabilityDomain,
81
		AddOperationCommand command = new AddOperationCommand(capabilityDomain,
82
		newOperation);
82
				newOperation);
83
	command.execute();
83
		command.execute();
84
84
85
	int newTotalOperations = WsdlUtils.getWSDLOperation(definition).length;
85
		int newTotalOperations = WsdlUtils.getWSDLOperation(definition).length;
86
	assertTrue(newTotalOperations == totalOperations + 1);
86
		assertTrue(newTotalOperations == totalOperations + 1);
87
87
88
	Operation operation = WsdlUtils.getWSDLOperation(definition)[newTotalOperations - 1];
88
		Operation operation = WsdlUtils.getWSDLOperation(definition)[newTotalOperations - 1];
89
	assertEquals("foo", operation.getName());
89
		assertEquals("foo", operation.getName());
90
	// TODO Check for Input, Output, Message and Part
90
		// TODO Check for Input, Output, Message and Part
91
    }
91
	}
92
92
93
}
93
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/AllOperationCommandTest.java (-63 / +63 lines)
Lines 24-91 Link Here
24
 */
24
 */
25
public class AllOperationCommandTest extends HyadesTestCase
25
public class AllOperationCommandTest extends HyadesTestCase
26
{
26
{
27
    /**
27
	/**
28
         * Constructor for AllOperationCommandTest.
28
	 * Constructor for AllOperationCommandTest.
29
         * 
29
	 * 
30
         * @param name
30
	 * @param name
31
         */
31
	 */
32
    public AllOperationCommandTest(String name)
32
	public AllOperationCommandTest(String name)
33
    {
33
	{
34
	super(name);
34
		super(name);
35
    }
35
	}
36
36
37
    /**
37
	/**
38
         * Returns the JUnit test suite that implements the
38
	 * Returns the JUnit test suite that implements the
39
         * <b>AllOperationCommandTest</b> definition.
39
	 * <b>AllOperationCommandTest</b> definition.
40
         */
40
	 */
41
    public static Test suite()
41
	public static Test suite()
42
    {
42
	{
43
	HyadesTestSuite allOperationCommandTest = new HyadesTestSuite(
43
		HyadesTestSuite allOperationCommandTest = new HyadesTestSuite(
44
		"AllOperationCommandTest");
44
				"AllOperationCommandTest");
45
	allOperationCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
45
		allOperationCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
46
		"C8E89291F2E4762CE3965FA0100711DB");
46
				"C8E89291F2E4762CE3965FA0100711DB");
47
47
48
	allOperationCommandTest.addTest(HyadesJUnitRunner
48
		allOperationCommandTest.addTest(HyadesJUnitRunner
49
		.getTest(AddExceptionCommandTest.class));
49
				.getTest(AddExceptionCommandTest.class));
50
50
51
	allOperationCommandTest.addTest(HyadesJUnitRunner
51
		allOperationCommandTest.addTest(HyadesJUnitRunner
52
		.getTest(AddOperationCommandTest.class));
52
				.getTest(AddOperationCommandTest.class));
53
53
54
	allOperationCommandTest.addTest(HyadesJUnitRunner
54
		allOperationCommandTest.addTest(HyadesJUnitRunner
55
		.getTest(AddParameterCommandTest.class));
55
				.getTest(AddParameterCommandTest.class));
56
56
57
	allOperationCommandTest.addTest(HyadesJUnitRunner
57
		allOperationCommandTest.addTest(HyadesJUnitRunner
58
		.getTest(ChangeInputParamTypeCommandTest.class));
58
				.getTest(ChangeInputParamTypeCommandTest.class));
59
59
60
	allOperationCommandTest.addTest(HyadesJUnitRunner
60
		allOperationCommandTest.addTest(HyadesJUnitRunner
61
		.getTest(ChangeOperationNameCommandTest.class));
61
				.getTest(ChangeOperationNameCommandTest.class));
62
62
63
	allOperationCommandTest.addTest(HyadesJUnitRunner
63
		allOperationCommandTest.addTest(HyadesJUnitRunner
64
		.getTest(ChangeOperationReturnTypeCommandTest.class));
64
				.getTest(ChangeOperationReturnTypeCommandTest.class));
65
65
66
	allOperationCommandTest.addTest(HyadesJUnitRunner
66
		allOperationCommandTest.addTest(HyadesJUnitRunner
67
		.getTest(RemoveExceptionCommandTest.class));
67
				.getTest(RemoveExceptionCommandTest.class));
68
68
69
	allOperationCommandTest.addTest(HyadesJUnitRunner
69
		allOperationCommandTest.addTest(HyadesJUnitRunner
70
		.getTest(RemoveOperationCommandTest.class));
70
				.getTest(RemoveOperationCommandTest.class));
71
71
72
	allOperationCommandTest.addTest(HyadesJUnitRunner
72
		allOperationCommandTest.addTest(HyadesJUnitRunner
73
		.getTest(RemoveParameterCommandTest.class));
73
				.getTest(RemoveParameterCommandTest.class));
74
	return allOperationCommandTest;
74
		return allOperationCommandTest;
75
    }
75
	}
76
76
77
    /**
77
	/**
78
         * @see junit.framework.TestCase#setUp()
78
	 * @see junit.framework.TestCase#setUp()
79
         */
79
	 */
80
    protected void setUp() throws Exception
80
	protected void setUp() throws Exception
81
    {
81
	{
82
    }
82
	}
83
83
84
    /**
84
	/**
85
         * @see junit.framework.TestCase#tearDown()
85
	 * @see junit.framework.TestCase#tearDown()
86
         */
86
	 */
87
    protected void tearDown() throws Exception
87
	protected void tearDown() throws Exception
88
    {
88
	{
89
    }
89
	}
90
90
91
}
91
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/AddExceptionCommandTest.java (-79 / +79 lines)
Lines 30-116 Link Here
30
 */
30
 */
31
public class AddExceptionCommandTest extends OperationCommandTestModel
31
public class AddExceptionCommandTest extends OperationCommandTestModel
32
{
32
{
33
    /**
33
	/**
34
         * Constructor for AddExceptionCommandTest.
34
	 * Constructor for AddExceptionCommandTest.
35
         * 
35
	 * 
36
         * @param name
36
	 * @param name
37
         */
37
	 */
38
    public AddExceptionCommandTest(String name)
38
	public AddExceptionCommandTest(String name)
39
    {
40
	super(name);
41
    }
42
43
    /**
44
         * Returns the JUnit test suite that implements the
45
         * <b>AddExceptionCommandTest</b> definition.
46
         */
47
    public static Test suite()
48
    {
49
	HyadesTestSuite addExceptionCommandTest = new HyadesTestSuite(
50
		"AddExceptionCommandTest");
51
	addExceptionCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
52
		"C254CB80544979D7AFA330D042F511DB");
53
54
	addExceptionCommandTest.addTest(new AddExceptionCommandTest(
55
		"testAddException"));
56
57
	return addExceptionCommandTest;
58
    }
59
60
    /**
61
         * @see junit.framework.TestCase#setUp()
62
         */
63
    protected void setUp() throws Exception
64
    {
65
	super.setUp();
66
    }
67
68
    /**
69
         * @see junit.framework.TestCase#tearDown()
70
         */
71
    protected void tearDown() throws Exception
72
    {
73
    }
74
75
    /**
76
         * testAddException
77
         * 
78
         * @throws Exception
79
         */
80
    public void testAddException() throws Exception
81
    {
82
	Operation operation = getOperation(START_SERVER_OPERATION_NAME);
83
84
	// If Base Fault already there then return
85
	java.util.List faultElements = WsdlUtils
86
		.getOperationFaultElements(operation);
87
	for (int i = 0; i < faultElements.size(); i++)
88
	{
39
	{
89
	    XSDElementDeclaration faultElement = (XSDElementDeclaration) faultElements
40
		super(name);
90
		    .get(i);
91
	    String type = WsdlUtils.getFaultType(faultElement);
92
	    if ("BaseFaultType".equals(type))
93
	    {
94
		throw new AssertionFailedError(
95
			"Base Fault already existing in operation "
96
				+ operation.getName());
97
	    }
98
	}
41
	}
99
42
100
	Fault newException = TestUtils
43
	/**
101
		.createNewException(definition, operation);
44
	 * Returns the JUnit test suite that implements the
102
	AddExceptionCommand command = new AddExceptionCommand(capabilityDomain,
45
	 * <b>AddExceptionCommandTest</b> definition.
103
		operation, newException);
46
	 */
104
	command.execute();
47
	public static Test suite()
105
48
	{
106
	// Verify that new fault properly added
49
		HyadesTestSuite addExceptionCommandTest = new HyadesTestSuite(
107
	faultElements = WsdlUtils.getOperationFaultElements(operation);
50
				"AddExceptionCommandTest");
108
	assertNotNull(faultElements);
51
		addExceptionCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
109
	assertTrue(faultElements.size() > 0);
52
				"C254CB80544979D7AFA330D042F511DB");
110
	XSDElementDeclaration faultElement = (XSDElementDeclaration) faultElements
53
111
		.get(faultElements.size() - 1);
54
		addExceptionCommandTest.addTest(new AddExceptionCommandTest(
112
	String type = WsdlUtils.getFaultType(faultElement);
55
				"testAddException"));
113
	assertEquals("BaseFaultType", type);
56
114
    }
57
		return addExceptionCommandTest;
58
	}
59
60
	/**
61
	 * @see junit.framework.TestCase#setUp()
62
	 */
63
	protected void setUp() throws Exception
64
	{
65
		super.setUp();
66
	}
67
68
	/**
69
	 * @see junit.framework.TestCase#tearDown()
70
	 */
71
	protected void tearDown() throws Exception
72
	{
73
	}
74
75
	/**
76
	 * testAddException
77
	 * 
78
	 * @throws Exception
79
	 */
80
	public void testAddException() throws Exception
81
	{
82
		Operation operation = getOperation(START_SERVER_OPERATION_NAME);
83
84
		// If Base Fault already there then return
85
		java.util.List faultElements = WsdlUtils
86
				.getOperationFaultElements(operation);
87
		for (int i = 0; i < faultElements.size(); i++)
88
		{
89
			XSDElementDeclaration faultElement = (XSDElementDeclaration) faultElements
90
					.get(i);
91
			String type = WsdlUtils.getFaultType(faultElement);
92
			if ("BaseFaultType".equals(type))
93
			{
94
				throw new AssertionFailedError(
95
						"Base Fault already existing in operation "
96
								+ operation.getName());
97
			}
98
		}
99
100
		Fault newException = TestUtils
101
				.createNewException(definition, operation);
102
		AddExceptionCommand command = new AddExceptionCommand(capabilityDomain,
103
				operation, newException);
104
		command.execute();
105
106
		// Verify that new fault properly added
107
		faultElements = WsdlUtils.getOperationFaultElements(operation);
108
		assertNotNull(faultElements);
109
		assertTrue(faultElements.size() > 0);
110
		XSDElementDeclaration faultElement = (XSDElementDeclaration) faultElements
111
				.get(faultElements.size() - 1);
112
		String type = WsdlUtils.getFaultType(faultElement);
113
		assertEquals("BaseFaultType", type);
114
	}
115
115
116
}
116
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/RemoveParameterCommandTest.java (-93 / +93 lines)
Lines 32-129 Link Here
32
 */
32
 */
33
public class RemoveParameterCommandTest extends OperationCommandTestModel
33
public class RemoveParameterCommandTest extends OperationCommandTestModel
34
{
34
{
35
    /**
35
	/**
36
         * Constructor for RemoveParameterCommandTest.
36
	 * Constructor for RemoveParameterCommandTest.
37
         * 
37
	 * 
38
         * @param name
38
	 * @param name
39
         */
39
	 */
40
    public RemoveParameterCommandTest(String name)
40
	public RemoveParameterCommandTest(String name)
41
    {
41
	{
42
	super(name);
42
		super(name);
43
    }
43
	}
44
44
45
    /**
45
	/**
46
         * Returns the JUnit test suite that implements the
46
	 * Returns the JUnit test suite that implements the
47
         * <b>RemoveParameterCommandTest</b> definition.
47
	 * <b>RemoveParameterCommandTest</b> definition.
48
         */
48
	 */
49
    public static Test suite()
49
	public static Test suite()
50
    {
50
	{
51
	HyadesTestSuite removeParameterCommandTest = new HyadesTestSuite(
51
		HyadesTestSuite removeParameterCommandTest = new HyadesTestSuite(
52
		"RemoveParameterCommandTest");
52
				"RemoveParameterCommandTest");
53
	removeParameterCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
53
		removeParameterCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
54
		.setId("C254CB80544979D715E181D042F611DB");
54
				.setId("C254CB80544979D715E181D042F611DB");
55
55
56
	removeParameterCommandTest.addTest(new RemoveParameterCommandTest(
56
		removeParameterCommandTest.addTest(new RemoveParameterCommandTest(
57
		"testRemoveParameter"));
57
				"testRemoveParameter"));
58
58
59
	return removeParameterCommandTest;
59
		return removeParameterCommandTest;
60
    }
60
	}
61
61
62
    /**
62
	/**
63
         * @see junit.framework.TestCase#setUp()
63
	 * @see junit.framework.TestCase#setUp()
64
         */
64
	 */
65
    protected void setUp() throws Exception
65
	protected void setUp() throws Exception
66
    {
66
	{
67
	super.setUp();
67
		super.setUp();
68
    }
68
	}
69
69
70
    /**
70
	/**
71
         * @see junit.framework.TestCase#tearDown()
71
	 * @see junit.framework.TestCase#tearDown()
72
         */
72
	 */
73
    protected void tearDown() throws Exception
73
	protected void tearDown() throws Exception
74
    {
74
	{
75
    }
75
	}
76
76
77
    /**
77
	/**
78
         * testRemoveParameter
78
	 * testRemoveParameter
79
         * 
79
	 * 
80
         * @throws Exception
80
	 * @throws Exception
81
         */
81
	 */
82
    public void testRemoveParameter() throws Exception
82
	public void testRemoveParameter() throws Exception
83
    {
83
	{
84
	Operation operation = getOperation(DEPLOY_APP_OPERATION_NAME);
84
		Operation operation = getOperation(DEPLOY_APP_OPERATION_NAME);
85
85
86
	XSDElementDeclaration oldParams[] = WsdlUtils
86
		XSDElementDeclaration oldParams[] = WsdlUtils
87
		.getOperationParams(operation);
87
				.getOperationParams(operation);
88
	assertNotNull(oldParams);
88
		assertNotNull(oldParams);
89
	assertEquals(2, oldParams.length);
89
		assertEquals(2, oldParams.length);
90
90
91
	String typeName = XsdUtils.getType(oldParams[0]);
91
		String typeName = XsdUtils.getType(oldParams[0]);
92
	DataType dataType = new DataType(typeName, oldParams[0]
92
		DataType dataType = new DataType(typeName, oldParams[0]
93
		.getTypeDefinition());
93
				.getTypeDefinition());
94
	String param_1_name = XsdUtils.getName(oldParams[0]);
94
		String param_1_name = XsdUtils.getName(oldParams[0]);
95
	InputParameter param_1 = new InputParameter(oldParams[0], dataType);
95
		InputParameter param_1 = new InputParameter(oldParams[0], dataType);
96
96
97
	RemoveParameterCommand command_1 = new RemoveParameterCommand(
97
		RemoveParameterCommand command_1 = new RemoveParameterCommand(
98
		operation, param_1);
98
				operation, param_1);
99
	command_1.execute();
99
		command_1.execute();
100
100
101
	// Verify that Param_1 got removed and another param is still in XSD
101
		// Verify that Param_1 got removed and another param is still in XSD
102
        // Model group
102
		// Model group
103
	oldParams = WsdlUtils.getOperationParams(operation);
103
		oldParams = WsdlUtils.getOperationParams(operation);
104
	assertNotNull(oldParams);
104
		assertNotNull(oldParams);
105
	assertEquals(1, oldParams.length);
105
		assertEquals(1, oldParams.length);
106
	String param_2_name = XsdUtils.getName(oldParams[0]);
106
		String param_2_name = XsdUtils.getName(oldParams[0]);
107
	assertNotSame(param_2_name, param_1_name);
107
		assertNotSame(param_2_name, param_1_name);
108
108
109
	// Now remove another param
109
		// Now remove another param
110
	typeName = XsdUtils.getType(oldParams[0]);
110
		typeName = XsdUtils.getType(oldParams[0]);
111
	dataType = new DataType(typeName, oldParams[0].getTypeDefinition());
111
		dataType = new DataType(typeName, oldParams[0].getTypeDefinition());
112
	InputParameter param_2 = new InputParameter(oldParams[0], dataType);
112
		InputParameter param_2 = new InputParameter(oldParams[0], dataType);
113
113
114
	RemoveParameterCommand command_2 = new RemoveParameterCommand(
114
		RemoveParameterCommand command_2 = new RemoveParameterCommand(
115
		operation, param_2);
115
				operation, param_2);
116
	command_2.execute();
116
		command_2.execute();
117
117
118
	// Verify that Param_1 got removed and XSD Model group is removed
118
		// Verify that Param_1 got removed and XSD Model group is removed
119
	oldParams = WsdlUtils.getOperationParams(operation);
119
		oldParams = WsdlUtils.getOperationParams(operation);
120
	assertNotNull(oldParams);
120
		assertNotNull(oldParams);
121
	assertEquals(0, oldParams.length);
121
		assertEquals(0, oldParams.length);
122
122
123
	Part part_0 = (Part) operation.getEInput().getEMessage().getEParts()
123
		Part part_0 = (Part) operation.getEInput().getEMessage().getEParts()
124
		.get(0);
124
				.get(0);
125
	XSDElementDeclaration element = part_0.getElementDeclaration();
125
		XSDElementDeclaration element = part_0.getElementDeclaration();
126
	assertNull(element.getAnonymousTypeDefinition());
126
		assertNull(element.getAnonymousTypeDefinition());
127
    }
127
	}
128
128
129
}
129
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/ChangeInputParamTypeCommandTest.java (-52 / +52 lines)
Lines 24-80 Link Here
24
 */
24
 */
25
public class ChangeInputParamTypeCommandTest extends OperationCommandTestModel
25
public class ChangeInputParamTypeCommandTest extends OperationCommandTestModel
26
{
26
{
27
    /**
27
	/**
28
         * Constructor for ChangeInputParamTypeCommandTest.
28
	 * Constructor for ChangeInputParamTypeCommandTest.
29
         * 
29
	 * 
30
         * @param name
30
	 * @param name
31
         */
31
	 */
32
    public ChangeInputParamTypeCommandTest(String name)
32
	public ChangeInputParamTypeCommandTest(String name)
33
    {
33
	{
34
	super(name);
34
		super(name);
35
    }
35
	}
36
36
37
    /**
37
	/**
38
         * Returns the JUnit test suite that implements the
38
	 * Returns the JUnit test suite that implements the
39
         * <b>ChangeInputParamTypeCommandTest</b> definition.
39
	 * <b>ChangeInputParamTypeCommandTest</b> definition.
40
         */
40
	 */
41
    public static Test suite()
41
	public static Test suite()
42
    {
42
	{
43
	HyadesTestSuite changeInputParamTypeCommandTest = new HyadesTestSuite(
43
		HyadesTestSuite changeInputParamTypeCommandTest = new HyadesTestSuite(
44
		"ChangeInputParamTypeCommandTest");
44
				"ChangeInputParamTypeCommandTest");
45
	changeInputParamTypeCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
45
		changeInputParamTypeCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
46
		.setId("C254CB80544979D7E8566B4042F511DB");
46
				.setId("C254CB80544979D7E8566B4042F511DB");
47
47
48
	changeInputParamTypeCommandTest
48
		changeInputParamTypeCommandTest
49
		.addTest(new ChangeInputParamTypeCommandTest(
49
				.addTest(new ChangeInputParamTypeCommandTest(
50
			"testChangeInputParamType"));
50
						"testChangeInputParamType"));
51
51
52
	return changeInputParamTypeCommandTest;
52
		return changeInputParamTypeCommandTest;
53
    }
53
	}
54
54
55
    /**
55
	/**
56
         * @see junit.framework.TestCase#setUp()
56
	 * @see junit.framework.TestCase#setUp()
57
         */
57
	 */
58
    protected void setUp() throws Exception
58
	protected void setUp() throws Exception
59
    {
59
	{
60
	super.setUp();
60
		super.setUp();
61
    }
61
	}
62
62
63
    /**
63
	/**
64
         * @see junit.framework.TestCase#tearDown()
64
	 * @see junit.framework.TestCase#tearDown()
65
         */
65
	 */
66
    protected void tearDown() throws Exception
66
	protected void tearDown() throws Exception
67
    {
67
	{
68
    }
68
	}
69
69
70
    /**
70
	/**
71
         * testChangeInputParamType
71
	 * testChangeInputParamType
72
         * 
72
	 * 
73
         * @throws Exception
73
	 * @throws Exception
74
         */
74
	 */
75
    public void testChangeInputParamType() throws Exception
75
	public void testChangeInputParamType() throws Exception
76
    {
76
	{
77
	// Enter your code here
77
		// Enter your code here
78
    }
78
	}
79
79
80
}
80
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/RemoveOperationCommandTest.java (-70 / +70 lines)
Lines 29-108 Link Here
29
 */
29
 */
30
public class RemoveOperationCommandTest extends OperationCommandTestModel
30
public class RemoveOperationCommandTest extends OperationCommandTestModel
31
{
31
{
32
    /**
32
	/**
33
         * Constructor for RemoveOperationCommandTest.
33
	 * Constructor for RemoveOperationCommandTest.
34
         * 
34
	 * 
35
         * @param name
35
	 * @param name
36
         */
36
	 */
37
    public RemoveOperationCommandTest(String name)
37
	public RemoveOperationCommandTest(String name)
38
    {
38
	{
39
	super(name);
39
		super(name);
40
    }
40
	}
41
41
42
    /**
42
	/**
43
         * Returns the JUnit test suite that implements the
43
	 * Returns the JUnit test suite that implements the
44
         * <b>RemoveOperationCommandTest</b> definition.
44
	 * <b>RemoveOperationCommandTest</b> definition.
45
         */
45
	 */
46
    public static Test suite()
46
	public static Test suite()
47
    {
47
	{
48
	HyadesTestSuite removeOperationCommandTest = new HyadesTestSuite(
48
		HyadesTestSuite removeOperationCommandTest = new HyadesTestSuite(
49
		"RemoveOperationCommandTest");
49
				"RemoveOperationCommandTest");
50
	removeOperationCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
50
		removeOperationCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
51
		.setId("C8E89291F2E4762CE8D08E90100311DB");
51
				.setId("C8E89291F2E4762CE8D08E90100311DB");
52
52
53
	removeOperationCommandTest.addTest(new RemoveOperationCommandTest(
53
		removeOperationCommandTest.addTest(new RemoveOperationCommandTest(
54
		"testRemoveOperation"));
54
				"testRemoveOperation"));
55
55
56
	return removeOperationCommandTest;
56
		return removeOperationCommandTest;
57
    }
57
	}
58
59
    /**
60
         * @see junit.framework.TestCase#setUp()
61
         */
62
    protected void setUp() throws Exception
63
    {
64
	super.setUp();
65
    }
66
67
    /**
68
         * @see junit.framework.TestCase#tearDown()
69
         */
70
    protected void tearDown() throws Exception
71
    {
72
    }
73
74
    /**
75
         * testRemoveOperation
76
         * 
77
         * @throws Exception
78
         */
79
    public void testRemoveOperation() throws Exception
80
    {
81
	int totalOperations = capability.getOperations().size();
82
	List opList = capability.getOperations();
83
	assertNotNull(opList);
84
	assertTrue(totalOperations > 0);
85
	Object object = opList.get(0);
86
	assertTrue(object instanceof Operation);
87
	Operation operation = (Operation) object;
88
	String opName = new String(operation.getName());
89
90
	RemoveOperationCommand command = new RemoveOperationCommand(
91
		capabilityDomain, operation);
92
	command.execute();
93
58
94
	int newTotalOperations = WsdlUtils.getWSDLOperation(definition).length;
59
	/**
95
	assertTrue(newTotalOperations == totalOperations - 1);
60
	 * @see junit.framework.TestCase#setUp()
61
	 */
62
	protected void setUp() throws Exception
63
	{
64
		super.setUp();
65
	}
96
66
97
	Operation[] operations = WsdlUtils.getWSDLOperation(definition);
67
	/**
98
	for (int i = 0; i < operations.length; i++)
68
	 * @see junit.framework.TestCase#tearDown()
69
	 */
70
	protected void tearDown() throws Exception
99
	{
71
	{
100
	    if (operations[i].getName().equals(opName))
101
		throw new AssertionFailedError("Operation " + opName
102
			+ " not removed properly");
103
	}
72
	}
104
73
105
	// TODO Check for Input, Output, Message and Part
74
	/**
106
    }
75
	 * testRemoveOperation
76
	 * 
77
	 * @throws Exception
78
	 */
79
	public void testRemoveOperation() throws Exception
80
	{
81
		int totalOperations = capability.getOperations().size();
82
		List opList = capability.getOperations();
83
		assertNotNull(opList);
84
		assertTrue(totalOperations > 0);
85
		Object object = opList.get(0);
86
		assertTrue(object instanceof Operation);
87
		Operation operation = (Operation) object;
88
		String opName = new String(operation.getName());
89
90
		RemoveOperationCommand command = new RemoveOperationCommand(
91
				capabilityDomain, operation);
92
		command.execute();
93
94
		int newTotalOperations = WsdlUtils.getWSDLOperation(definition).length;
95
		assertTrue(newTotalOperations == totalOperations - 1);
96
97
		Operation[] operations = WsdlUtils.getWSDLOperation(definition);
98
		for (int i = 0; i < operations.length; i++)
99
		{
100
			if (operations[i].getName().equals(opName))
101
				throw new AssertionFailedError("Operation " + opName
102
						+ " not removed properly");
103
		}
104
105
		// TODO Check for Input, Output, Message and Part
106
	}
107
107
108
}
108
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/OperationCommandTestModel.java (-35 / +35 lines)
Lines 22-67 Link Here
22
22
23
public class OperationCommandTestModel extends CapabilityTestModel
23
public class OperationCommandTestModel extends CapabilityTestModel
24
{
24
{
25
    protected String START_SERVER_OPERATION_NAME = "startServer";
25
	protected String START_SERVER_OPERATION_NAME = "startServer";
26
26
27
    protected String START_APP_OPERATION_NAME = "startApp";
27
	protected String START_APP_OPERATION_NAME = "startApp";
28
28
29
    protected String DEPLOY_APP_OPERATION_NAME = "deployApp";
29
	protected String DEPLOY_APP_OPERATION_NAME = "deployApp";
30
30
31
    protected String STOP_APP_OPERATION_NAME = "stopApp";
31
	protected String STOP_APP_OPERATION_NAME = "stopApp";
32
32
33
    protected String STOP_SERVER_OPERATION_NAME = "stopServer";
33
	protected String STOP_SERVER_OPERATION_NAME = "stopServer";
34
34
35
    public OperationCommandTestModel(String name)
35
	public OperationCommandTestModel(String name)
36
    {
36
	{
37
	this(name, Activator.PLUGIN_ID + "/"
37
		this(name, Activator.PLUGIN_ID + "/"
38
		+ "testfiles/capability/command/operation/Server.mcap");
38
				+ "testfiles/capability/command/operation/Server.mcap");
39
    }
39
	}
40
40
41
    public OperationCommandTestModel(String name, String CapabilityIFilePath)
41
	public OperationCommandTestModel(String name, String CapabilityIFilePath)
42
    {
42
	{
43
	super(name, CapabilityIFilePath);
43
		super(name, CapabilityIFilePath);
44
    }
44
	}
45
45
46
    protected Operation getOperation(String operationName)
46
	protected Operation getOperation(String operationName)
47
    {
48
	List operationList = capability.getOperations();
49
	if (operationList == null || operationList.size() == 0)
50
	    throw new AssertionFailedError(
51
		    "No operations found in capability file -- "
52
			    + CAPABILITY_FILE_PATH);
53
	Operation operation = null;
54
	for (int i = 0; i < operationList.size(); i++)
55
	{
47
	{
56
	    operation = (Operation) operationList.get(i);
48
		List operationList = capability.getOperations();
57
	    if (operationName.equals(operation.getName()))
49
		if (operationList == null || operationList.size() == 0)
58
		break;
50
			throw new AssertionFailedError(
51
					"No operations found in capability file -- "
52
							+ CAPABILITY_FILE_PATH);
53
		Operation operation = null;
54
		for (int i = 0; i < operationList.size(); i++)
55
		{
56
			operation = (Operation) operationList.get(i);
57
			if (operationName.equals(operation.getName()))
58
				break;
59
		}
60
		if (operation == null)
61
			throw new AssertionFailedError("No operations found by name "
62
					+ operationName + " in capability file -- "
63
					+ CAPABILITY_FILE_PATH);
64
		return operation;
59
	}
65
	}
60
	if (operation == null)
61
	    throw new AssertionFailedError("No operations found by name "
62
		    + operationName + " in capability file -- "
63
		    + CAPABILITY_FILE_PATH);
64
	return operation;
65
    }
66
66
67
}
67
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/NewTestParameter.java (-17 / +17 lines)
Lines 20-45 Link Here
20
20
21
public class NewTestParameter
21
public class NewTestParameter
22
{
22
{
23
    private String _paramName;
23
	private String _paramName;
24
24
25
    private DataType _dataType;
25
	private DataType _dataType;
26
26
27
    public NewTestParameter(String paramName, DataType dataType)
27
	public NewTestParameter(String paramName, DataType dataType)
28
    {
28
	{
29
	_paramName = paramName;
29
		_paramName = paramName;
30
	_dataType = dataType;
30
		_dataType = dataType;
31
    }
31
	}
32
32
33
    public InputParameter getParameter()
33
	public InputParameter getParameter()
34
    {
34
	{
35
	XSDElementDeclaration _element = XSDFactory.eINSTANCE
35
		XSDElementDeclaration _element = XSDFactory.eINSTANCE
36
		.createXSDElementDeclaration();
36
				.createXSDElementDeclaration();
37
	_element.setName(_paramName);
37
		_element.setName(_paramName);
38
38
39
	XSDTypeDefinition newType = _dataType.getTypeDefinition();
39
		XSDTypeDefinition newType = _dataType.getTypeDefinition();
40
	_element.setTypeDefinition(newType);
40
		_element.setTypeDefinition(newType);
41
41
42
	return new InputParameter(_element, _dataType);
42
		return new InputParameter(_element, _dataType);
43
    }
43
	}
44
44
45
}
45
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/AddParameterCommandTest.java (-222 / +222 lines)
Lines 37-262 Link Here
37
 */
37
 */
38
public class AddParameterCommandTest extends OperationCommandTestModel
38
public class AddParameterCommandTest extends OperationCommandTestModel
39
{
39
{
40
    /**
40
	/**
41
         * Constructor for AddParameterCommandTest.
41
	 * Constructor for AddParameterCommandTest.
42
         * 
42
	 * 
43
         * @param name
43
	 * @param name
44
         */
44
	 */
45
    public AddParameterCommandTest(String name)
45
	public AddParameterCommandTest(String name)
46
    {
46
	{
47
	super(name);
47
		super(name);
48
    }
48
	}
49
49
50
    /**
50
	/**
51
         * Returns the JUnit test suite that implements the
51
	 * Returns the JUnit test suite that implements the
52
         * <b>AddParameterCommandTest</b> definition.
52
	 * <b>AddParameterCommandTest</b> definition.
53
         */
53
	 */
54
    public static Test suite()
54
	public static Test suite()
55
    {
55
	{
56
	HyadesTestSuite addParameterCommandTest = new HyadesTestSuite(
56
		HyadesTestSuite addParameterCommandTest = new HyadesTestSuite(
57
		"AddParameterCommandTest");
57
				"AddParameterCommandTest");
58
	addParameterCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
58
		addParameterCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
59
		"C254CB80544979D7CEB7E2E042F511DB");
59
				"C254CB80544979D7CEB7E2E042F511DB");
60
60
61
	addParameterCommandTest.addTest(new AddParameterCommandTest(
61
		addParameterCommandTest.addTest(new AddParameterCommandTest(
62
		"testAddParameter_1"));
62
				"testAddParameter_1"));
63
	addParameterCommandTest.addTest(new AddParameterCommandTest(
63
		addParameterCommandTest.addTest(new AddParameterCommandTest(
64
		"testAddParameter_2"));
64
				"testAddParameter_2"));
65
	addParameterCommandTest.addTest(new AddParameterCommandTest(
65
		addParameterCommandTest.addTest(new AddParameterCommandTest(
66
		"testAddParameter_3"));
66
				"testAddParameter_3"));
67
	addParameterCommandTest.addTest(new AddParameterCommandTest(
67
		addParameterCommandTest.addTest(new AddParameterCommandTest(
68
		"testAddParameter_4"));
68
				"testAddParameter_4"));
69
69
70
	return addParameterCommandTest;
70
		return addParameterCommandTest;
71
    }
71
	}
72
72
73
    /**
73
	/**
74
         * @see junit.framework.TestCase#setUp()
74
	 * @see junit.framework.TestCase#setUp()
75
         */
75
	 */
76
    protected void setUp() throws Exception
76
	protected void setUp() throws Exception
77
    {
77
	{
78
	super.setUp();
78
		super.setUp();
79
    }
79
	}
80
80
81
    /**
81
	/**
82
         * @see junit.framework.TestCase#tearDown()
82
	 * @see junit.framework.TestCase#tearDown()
83
         */
83
	 */
84
    protected void tearDown() throws Exception
84
	protected void tearDown() throws Exception
85
    {
85
	{
86
    }
86
	}
87
87
88
    /**
88
	/**
89
         * Some of the input parameter may be defined as<br>
89
	 * Some of the input parameter may be defined as<br>
90
         * <br>
90
	 * <br>
91
         * 
91
	 * 
92
         * &lt; element name="port" type="int"/ &gt;<br>
92
	 * &lt; element name="port" type="int"/ &gt;<br>
93
         * <br>
93
	 * <br>
94
         * 
94
	 * 
95
         * So if we add a new parameter we have to move this existing paramater
95
	 * So if we add a new parameter we have to move this existing paramater into
96
         * into XSDModelGroup element reference Such as<br>
96
	 * XSDModelGroup element reference Such as<br>
97
         * <br>
97
	 * <br>
98
         * 
98
	 * 
99
         * &lt; element name="port" &gt; <br>
99
	 * &lt; element name="port" &gt; <br>
100
         * &lt; complexType &gt; <br>
100
	 * &lt; complexType &gt; <br>
101
         * &lt; sequence &gt; <br>
101
	 * &lt; sequence &gt; <br>
102
         * &lt; element name="port" type="int"/ &gt; <br>
102
	 * &lt; element name="port" type="int"/ &gt; <br>
103
         * &lt; element name="conntype" type="string"/ &gt; <br>
103
	 * &lt; element name="conntype" type="string"/ &gt; <br>
104
         * &lt; /sequence &gt; <br>
104
	 * &lt; /sequence &gt; <br>
105
         * &lt; /complexType &gt; <br>
105
	 * &lt; /complexType &gt; <br>
106
         * &lt; /element &gt; <br>
106
	 * &lt; /element &gt; <br>
107
         * 
107
	 * 
108
         * @throws Exception
108
	 * @throws Exception
109
         */
109
	 */
110
    public void testAddParameter_1() throws Exception
110
	public void testAddParameter_1() throws Exception
111
    {
111
	{
112
	Operation operation = getOperation(START_APP_OPERATION_NAME);
112
		Operation operation = getOperation(START_APP_OPERATION_NAME);
113
	XSDElementDeclaration[] oldParams = WsdlUtils
113
		XSDElementDeclaration[] oldParams = WsdlUtils
114
		.getOperationParams(operation);
114
				.getOperationParams(operation);
115
	assertNotNull(oldParams);
115
		assertNotNull(oldParams);
116
	assertTrue(oldParams.length > 0);
116
		assertTrue(oldParams.length > 0);
117
	XSDElementDeclaration lastParam = oldParams[oldParams.length - 1];
117
		XSDElementDeclaration lastParam = oldParams[oldParams.length - 1];
118
118
119
	String paramName = "serverHome";
119
		String paramName = "serverHome";
120
	DataType dataType = TestUtils.getDataType("string");
120
		DataType dataType = TestUtils.getDataType("string");
121
	InputParameter param = TestUtils
121
		InputParameter param = TestUtils
122
		.createNewParameter(paramName, dataType);
122
				.createNewParameter(paramName, dataType);
123
123
124
	AddParameterCommand command = new AddParameterCommand(operation, param);
124
		AddParameterCommand command = new AddParameterCommand(operation, param);
125
	command.execute();
125
		command.execute();
126
126
127
	// Verify the new parameter
127
		// Verify the new parameter
128
	XSDElementDeclaration[] newParams = WsdlUtils
128
		XSDElementDeclaration[] newParams = WsdlUtils
129
		.getOperationParams(operation);
129
				.getOperationParams(operation);
130
	assertNotNull(newParams);
130
		assertNotNull(newParams);
131
	assertEquals(oldParams.length + 1, newParams.length);
131
		assertEquals(oldParams.length + 1, newParams.length);
132
132
133
	XSDElementDeclaration newParam = newParams[newParams.length - 1];
133
		XSDElementDeclaration newParam = newParams[newParams.length - 1];
134
	assertEquals(param.getXSDElementDeclaration(), newParam);
134
		assertEquals(param.getXSDElementDeclaration(), newParam);
135
135
136
	// Verify Existing param moved to the XSD model group
136
		// Verify Existing param moved to the XSD model group
137
	XSDElementDeclaration existingParam = newParams[newParams.length - 2];
137
		XSDElementDeclaration existingParam = newParams[newParams.length - 2];
138
	assertEquals(lastParam.getName(), existingParam.getName());
138
		assertEquals(lastParam.getName(), existingParam.getName());
139
	assertEquals(lastParam.getTargetNamespace(), existingParam
139
		assertEquals(lastParam.getTargetNamespace(), existingParam
140
		.getTargetNamespace());
140
				.getTargetNamespace());
141
	assertEquals(lastParam.getSchema(), existingParam.getSchema());
141
		assertEquals(lastParam.getSchema(), existingParam.getSchema());
142
    }
142
	}
143
143
144
    /**
144
	/**
145
         * This will test that new parameter is added to the existing XSD model
145
	 * This will test that new parameter is added to the existing XSD model
146
         * group.
146
	 * group.
147
         * 
147
	 * 
148
         * @throws Exception
148
	 * @throws Exception
149
         */
149
	 */
150
    public void testAddParameter_2() throws Exception
150
	public void testAddParameter_2() throws Exception
151
    {
151
	{
152
	Operation operation = getOperation(DEPLOY_APP_OPERATION_NAME);
152
		Operation operation = getOperation(DEPLOY_APP_OPERATION_NAME);
153
	XSDElementDeclaration[] oldParams = WsdlUtils
153
		XSDElementDeclaration[] oldParams = WsdlUtils
154
		.getOperationParams(operation);
154
				.getOperationParams(operation);
155
	assertNotNull(oldParams);
155
		assertNotNull(oldParams);
156
	assertTrue(oldParams.length > 0);
156
		assertTrue(oldParams.length > 0);
157
157
158
	String paramName = "jvmHome";
158
		String paramName = "jvmHome";
159
	DataType dataType = TestUtils.getDataType("string");
159
		DataType dataType = TestUtils.getDataType("string");
160
	InputParameter param = TestUtils
160
		InputParameter param = TestUtils
161
		.createNewParameter(paramName, dataType);
161
				.createNewParameter(paramName, dataType);
162
162
163
	AddParameterCommand command = new AddParameterCommand(operation, param);
163
		AddParameterCommand command = new AddParameterCommand(operation, param);
164
	command.execute();
164
		command.execute();
165
165
166
	// Verify the new parameter
166
		// Verify the new parameter
167
	XSDElementDeclaration[] newParams = WsdlUtils
167
		XSDElementDeclaration[] newParams = WsdlUtils
168
		.getOperationParams(operation);
168
				.getOperationParams(operation);
169
	assertNotNull(newParams);
169
		assertNotNull(newParams);
170
	assertEquals(oldParams.length + 1, newParams.length);
170
		assertEquals(oldParams.length + 1, newParams.length);
171
171
172
	XSDElementDeclaration newParam = newParams[newParams.length - 1];
172
		XSDElementDeclaration newParam = newParams[newParams.length - 1];
173
	assertEquals(param.getXSDElementDeclaration(), newParam);
173
		assertEquals(param.getXSDElementDeclaration(), newParam);
174
    }
174
	}
175
175
176
    /**
176
	/**
177
         * This will test that new parameter addition action should create new
177
	 * This will test that new parameter addition action should create new XSD
178
         * XSD model group.
178
	 * model group.
179
         * 
179
	 * 
180
         * @throws Exception
180
	 * @throws Exception
181
         */
181
	 */
182
    public void testAddParameter_3() throws Exception
182
	public void testAddParameter_3() throws Exception
183
    {
183
	{
184
	Operation operation = getOperation(STOP_SERVER_OPERATION_NAME);
184
		Operation operation = getOperation(STOP_SERVER_OPERATION_NAME);
185
	XSDElementDeclaration[] oldParams = WsdlUtils
185
		XSDElementDeclaration[] oldParams = WsdlUtils
186
		.getOperationParams(operation);
186
				.getOperationParams(operation);
187
	assertNotNull(oldParams);
187
		assertNotNull(oldParams);
188
	assertEquals(0, oldParams.length);
188
		assertEquals(0, oldParams.length);
189
189
190
	String paramName = "serverVersion";
190
		String paramName = "serverVersion";
191
	DataType dataType = TestUtils.getDataType("int");
191
		DataType dataType = TestUtils.getDataType("int");
192
	InputParameter param = TestUtils
192
		InputParameter param = TestUtils
193
		.createNewParameter(paramName, dataType);
193
				.createNewParameter(paramName, dataType);
194
194
195
	AddParameterCommand command = new AddParameterCommand(operation, param);
195
		AddParameterCommand command = new AddParameterCommand(operation, param);
196
	command.execute();
196
		command.execute();
197
197
198
	// Verify the new parameter
198
		// Verify the new parameter
199
	XSDElementDeclaration[] newParams = WsdlUtils
199
		XSDElementDeclaration[] newParams = WsdlUtils
200
		.getOperationParams(operation);
200
				.getOperationParams(operation);
201
	assertNotNull(newParams);
201
		assertNotNull(newParams);
202
	assertEquals(oldParams.length + 1, newParams.length);
202
		assertEquals(oldParams.length + 1, newParams.length);
203
203
204
	XSDElementDeclaration newParam = newParams[newParams.length - 1];
204
		XSDElementDeclaration newParam = newParams[newParams.length - 1];
205
	assertEquals(param.getXSDElementDeclaration(), newParam);
205
		assertEquals(param.getXSDElementDeclaration(), newParam);
206
    }
206
	}
207
207
208
    /**
208
	/**
209
         * This will create a new parameter by passing the Complex data type.
209
	 * This will create a new parameter by passing the Complex data type.
210
         * 
210
	 * 
211
         * @throws Exception
211
	 * @throws Exception
212
         */
212
	 */
213
    public void testAddParameter_4() throws Exception
213
	public void testAddParameter_4() throws Exception
214
    {
214
	{
215
	Operation operation = getOperation(DEPLOY_APP_OPERATION_NAME);
215
		Operation operation = getOperation(DEPLOY_APP_OPERATION_NAME);
216
	XSDElementDeclaration[] oldParams = WsdlUtils
216
		XSDElementDeclaration[] oldParams = WsdlUtils
217
		.getOperationParams(operation);
217
				.getOperationParams(operation);
218
	assertNotNull(oldParams);
218
		assertNotNull(oldParams);
219
219
220
	String paramName = "jvmVersion";
220
		String paramName = "jvmVersion";
221
	// Get the complex type from some XSD
221
		// Get the complex type from some XSD
222
	String xsdFilePath = Activator.PLUGIN_ID + "/"
222
		String xsdFilePath = Activator.PLUGIN_ID + "/"
223
		+ "testfiles/xsd/common.xsd";
223
				+ "testfiles/xsd/common.xsd";
224
	List complexTypes = TestUtils.getComplexTypes(xsdFilePath);
224
		List complexTypes = TestUtils.getComplexTypes(xsdFilePath);
225
	assertNotNull(complexTypes);
225
		assertNotNull(complexTypes);
226
	assertTrue(complexTypes.size() > 0);
226
		assertTrue(complexTypes.size() > 0);
227
	XSDTypeDefinition complexType = (XSDTypeDefinition) complexTypes.get(0);
227
		XSDTypeDefinition complexType = (XSDTypeDefinition) complexTypes.get(0);
228
	String typeName = XsdUtils.getType(complexType);
228
		String typeName = XsdUtils.getType(complexType);
229
229
230
	DataType dataType = new DataType(typeName, complexType);
230
		DataType dataType = new DataType(typeName, complexType);
231
	InputParameter param = TestUtils
231
		InputParameter param = TestUtils
232
		.createNewParameter(paramName, dataType);
232
				.createNewParameter(paramName, dataType);
233
233
234
	AddParameterCommand command = new AddParameterCommand(operation, param);
234
		AddParameterCommand command = new AddParameterCommand(operation, param);
235
	command.execute();
235
		command.execute();
236
236
237
	// Verify the new parameter
237
		// Verify the new parameter
238
	XSDElementDeclaration[] newParams = WsdlUtils
238
		XSDElementDeclaration[] newParams = WsdlUtils
239
		.getOperationParams(operation);
239
				.getOperationParams(operation);
240
	assertNotNull(newParams);
240
		assertNotNull(newParams);
241
	assertEquals(oldParams.length + 1, newParams.length);
241
		assertEquals(oldParams.length + 1, newParams.length);
242
242
243
	XSDElementDeclaration newParam = newParams[newParams.length - 1];
243
		XSDElementDeclaration newParam = newParams[newParams.length - 1];
244
	assertEquals(param.getXSDElementDeclaration(), newParam);
244
		assertEquals(param.getXSDElementDeclaration(), newParam);
245
245
246
	// Verify the import element
246
		// Verify the import element
247
	String typeNS = newParam.getTypeDefinition().getTargetNamespace();
247
		String typeNS = newParam.getTypeDefinition().getTargetNamespace();
248
	XSDImport[] imports = XsdUtils.getAllXSDImports(newParam.getSchema());
248
		XSDImport[] imports = XsdUtils.getAllXSDImports(newParam.getSchema());
249
	assertNotNull(imports);
249
		assertNotNull(imports);
250
	assertTrue(imports.length > 0);
250
		assertTrue(imports.length > 0);
251
	boolean found = false;
251
		boolean found = false;
252
	for (int i = 0; i < imports.length; i++)
252
		for (int i = 0; i < imports.length; i++)
253
	{
253
		{
254
	    if (imports[i].getNamespace().equals(typeNS))
254
			if (imports[i].getNamespace().equals(typeNS))
255
		found = true;
255
				found = true;
256
	}
256
		}
257
	if (!found)
257
		if (!found)
258
	    throw new AssertionFailedError(
258
			throw new AssertionFailedError(
259
		    "XSD Import element not added while adding new parameter "
259
					"XSD Import element not added while adding new parameter "
260
			    + "which has complex kind of data type");
260
							+ "which has complex kind of data type");
261
    }
261
	}
262
}
262
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/ChangeOperationNameCommandTest.java (-69 / +69 lines)
Lines 29-105 Link Here
29
 */
29
 */
30
public class ChangeOperationNameCommandTest extends OperationCommandTestModel
30
public class ChangeOperationNameCommandTest extends OperationCommandTestModel
31
{
31
{
32
    /**
32
	/**
33
         * Constructor for ChangeOperationNameCommandTest.
33
	 * Constructor for ChangeOperationNameCommandTest.
34
         * 
34
	 * 
35
         * @param name
35
	 * @param name
36
         */
36
	 */
37
    public ChangeOperationNameCommandTest(String name)
37
	public ChangeOperationNameCommandTest(String name)
38
    {
38
	{
39
	super(name);
39
		super(name);
40
    }
40
	}
41
41
42
    /**
42
	/**
43
         * Returns the JUnit test suite that implements the
43
	 * Returns the JUnit test suite that implements the
44
         * <b>ChangeOperationNameCommandTest</b> definition.
44
	 * <b>ChangeOperationNameCommandTest</b> definition.
45
         */
45
	 */
46
    public static Test suite()
46
	public static Test suite()
47
    {
47
	{
48
	HyadesTestSuite changeOperationNameCommandTest = new HyadesTestSuite(
48
		HyadesTestSuite changeOperationNameCommandTest = new HyadesTestSuite(
49
		"ChangeOperationNameCommandTest");
49
				"ChangeOperationNameCommandTest");
50
	changeOperationNameCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
50
		changeOperationNameCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
51
		.setId("C8E89291F2E4762C91E35FC0100511DB");
51
				.setId("C8E89291F2E4762C91E35FC0100511DB");
52
52
53
	changeOperationNameCommandTest
53
		changeOperationNameCommandTest
54
		.addTest(new ChangeOperationNameCommandTest(
54
				.addTest(new ChangeOperationNameCommandTest(
55
			"testChangeOperationName"));
55
						"testChangeOperationName"));
56
56
57
	return changeOperationNameCommandTest;
57
		return changeOperationNameCommandTest;
58
    }
58
	}
59
59
60
    /**
60
	/**
61
         * @see junit.framework.TestCase#setUp()
61
	 * @see junit.framework.TestCase#setUp()
62
         */
62
	 */
63
    protected void setUp() throws Exception
63
	protected void setUp() throws Exception
64
    {
64
	{
65
	super.setUp();
65
		super.setUp();
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * @see junit.framework.TestCase#tearDown()
69
	 * @see junit.framework.TestCase#tearDown()
70
         */
70
	 */
71
    protected void tearDown() throws Exception
71
	protected void tearDown() throws Exception
72
    {
72
	{
73
    }
73
	}
74
75
    /**
76
         * testChangeOperationName
77
         * 
78
         * @throws Exception
79
         */
80
    public void testChangeOperationName() throws Exception
81
    {
82
	List opList = capability.getOperations();
83
	int totalOperations = opList.size();
84
	assertNotNull(opList);
85
	assertTrue(totalOperations > 0);
86
	Object object = opList.get(0);
87
	assertTrue(object instanceof Operation);
88
	Operation operation = (Operation) object;
89
	String oldOpName = new String(operation.getName());
90
	String newOpName = new String("Bar");
91
92
	ChangeOperationNameCommand command = new ChangeOperationNameCommand(
93
		operation, newOpName);
94
	command.execute();
95
74
96
	Operation[] operations = WsdlUtils.getWSDLOperation(definition);
75
	/**
97
	for (int i = 0; i < operations.length; i++)
76
	 * testChangeOperationName
77
	 * 
78
	 * @throws Exception
79
	 */
80
	public void testChangeOperationName() throws Exception
98
	{
81
	{
99
	    if (operations[i].getName().equals(oldOpName))
82
		List opList = capability.getOperations();
100
		throw new AssertionFailedError("Operation name " + oldOpName
83
		int totalOperations = opList.size();
101
			+ " not changed properly");
84
		assertNotNull(opList);
85
		assertTrue(totalOperations > 0);
86
		Object object = opList.get(0);
87
		assertTrue(object instanceof Operation);
88
		Operation operation = (Operation) object;
89
		String oldOpName = new String(operation.getName());
90
		String newOpName = new String("Bar");
91
92
		ChangeOperationNameCommand command = new ChangeOperationNameCommand(
93
				operation, newOpName);
94
		command.execute();
95
96
		Operation[] operations = WsdlUtils.getWSDLOperation(definition);
97
		for (int i = 0; i < operations.length; i++)
98
		{
99
			if (operations[i].getName().equals(oldOpName))
100
				throw new AssertionFailedError("Operation name " + oldOpName
101
						+ " not changed properly");
102
		}
102
	}
103
	}
103
    }
104
104
105
}
105
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/RemoveExceptionCommandTest.java (-72 / +72 lines)
Lines 30-105 Link Here
30
 */
30
 */
31
public class RemoveExceptionCommandTest extends OperationCommandTestModel
31
public class RemoveExceptionCommandTest extends OperationCommandTestModel
32
{
32
{
33
    /**
33
	/**
34
         * Constructor for RemoveExceptionCommandTest.
34
	 * Constructor for RemoveExceptionCommandTest.
35
         * 
35
	 * 
36
         * @param name
36
	 * @param name
37
         */
37
	 */
38
    public RemoveExceptionCommandTest(String name)
38
	public RemoveExceptionCommandTest(String name)
39
    {
39
	{
40
	super(name);
40
		super(name);
41
    }
41
	}
42
42
43
    /**
43
	/**
44
         * Returns the JUnit test suite that implements the
44
	 * Returns the JUnit test suite that implements the
45
         * <b>RemoveExceptionCommandTest</b> definition.
45
	 * <b>RemoveExceptionCommandTest</b> definition.
46
         */
46
	 */
47
    public static Test suite()
47
	public static Test suite()
48
    {
48
	{
49
	HyadesTestSuite removeExceptionCommandTest = new HyadesTestSuite(
49
		HyadesTestSuite removeExceptionCommandTest = new HyadesTestSuite(
50
		"RemoveExceptionCommandTest");
50
				"RemoveExceptionCommandTest");
51
	removeExceptionCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
51
		removeExceptionCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
52
		.setId("C254CB80544979D7FF7F38B042F511DB");
52
				.setId("C254CB80544979D7FF7F38B042F511DB");
53
53
54
	removeExceptionCommandTest.addTest(new RemoveExceptionCommandTest(
54
		removeExceptionCommandTest.addTest(new RemoveExceptionCommandTest(
55
		"testRemoveException"));
55
				"testRemoveException"));
56
56
57
	return removeExceptionCommandTest;
57
		return removeExceptionCommandTest;
58
    }
58
	}
59
59
60
    /**
60
	/**
61
         * @see junit.framework.TestCase#setUp()
61
	 * @see junit.framework.TestCase#setUp()
62
         */
62
	 */
63
    protected void setUp() throws Exception
63
	protected void setUp() throws Exception
64
    {
64
	{
65
	super.setUp();
65
		super.setUp();
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * @see junit.framework.TestCase#tearDown()
69
	 * @see junit.framework.TestCase#tearDown()
70
         */
70
	 */
71
    protected void tearDown() throws Exception
71
	protected void tearDown() throws Exception
72
    {
72
	{
73
    }
73
	}
74
74
75
    /**
75
	/**
76
         * testRemoveException
76
	 * testRemoveException
77
         * 
77
	 * 
78
         * @throws Exception
78
	 * @throws Exception
79
         */
79
	 */
80
    public void testRemoveException() throws Exception
80
	public void testRemoveException() throws Exception
81
    {
81
	{
82
	Operation operation = getOperation(STOP_SERVER_OPERATION_NAME);
82
		Operation operation = getOperation(STOP_SERVER_OPERATION_NAME);
83
83
84
	List faultList = operation.getEFaults();
84
		List faultList = operation.getEFaults();
85
	assertNotNull(faultList);
85
		assertNotNull(faultList);
86
	assertTrue(faultList.size() > 0);
86
		assertTrue(faultList.size() > 0);
87
	int oldFaultSizes = faultList.size();
87
		int oldFaultSizes = faultList.size();
88
88
89
	Fault fault = (Fault) faultList.get(0);
89
		Fault fault = (Fault) faultList.get(0);
90
	Message faultMessage = fault.getEMessage();
90
		Message faultMessage = fault.getEMessage();
91
91
92
	RemoveExceptionCommand command = new RemoveExceptionCommand(
92
		RemoveExceptionCommand command = new RemoveExceptionCommand(
93
		capabilityDomain, operation, fault);
93
				capabilityDomain, operation, fault);
94
	command.execute();
94
		command.execute();
95
95
96
	// Verify its removed properly
96
		// Verify its removed properly
97
	List newFaultList = operation.getEFaults();
97
		List newFaultList = operation.getEFaults();
98
	assertNotNull(newFaultList);
98
		assertNotNull(newFaultList);
99
	assertEquals(oldFaultSizes - 1, newFaultList.size());
99
		assertEquals(oldFaultSizes - 1, newFaultList.size());
100
100
101
	int index = capabilityDomain.getDefinition().getEMessages().indexOf(
101
		int index = capabilityDomain.getCapability().getDefinition()
102
		faultMessage);
102
				.getEMessages().indexOf(faultMessage);
103
	assertEquals(-1, index);
103
		assertEquals(-1, index);
104
    }
104
	}
105
}
105
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/NewTestOperation.java (-129 / +129 lines)
Lines 34-169 Link Here
34
public class NewTestOperation
34
public class NewTestOperation
35
{
35
{
36
36
37
    private XSDSchema typesSchema;
37
	private XSDSchema typesSchema;
38
38
39
    private Definition definition;
39
	private Definition definition;
40
40
41
    public NewTestOperation(Definition definition)
41
	public NewTestOperation(Definition definition)
42
    {
42
	{
43
	this.definition = definition;
43
		this.definition = definition;
44
	this.typesSchema = WsdlUtils.getSchema(definition, definition
44
		this.typesSchema = WsdlUtils.getSchema(definition, definition
45
		.getTargetNamespace());
45
				.getTargetNamespace());
46
    }
46
	}
47
47
48
    public Operation getOperation()
48
	public Operation getOperation()
49
    {
49
	{
50
	Operation operation = WSDLFactory.eINSTANCE.createOperation();
50
		Operation operation = WSDLFactory.eINSTANCE.createOperation();
51
	operation.setName("Food");
51
		operation.setName("Food");
52
	operation.setEnclosingDefinition(definition);
52
		operation.setEnclosingDefinition(definition);
53
53
54
	Input input = prepareOperationInput();
54
		Input input = prepareOperationInput();
55
	operation.setEInput(input);
55
		operation.setEInput(input);
56
56
57
	Output output = prepareOperationOutput();
57
		Output output = prepareOperationOutput();
58
	operation.setEOutput(output);
58
		operation.setEOutput(output);
59
59
60
	prepareFaultNS();
60
		prepareFaultNS();
61
	Fault fault = prepareOperationFault();
61
		Fault fault = prepareOperationFault();
62
	operation.addFault(fault);
62
		operation.addFault(fault);
63
63
64
	return operation;
64
		return operation;
65
    }
65
	}
66
66
67
    private void prepareFaultNS()
67
	private void prepareFaultNS()
68
    {
68
	{
69
	String faultNS = "http://docs.oasis-open.org/wsrf/bf-2";
69
		String faultNS = "http://docs.oasis-open.org/wsrf/bf-2";
70
	if (WsdlUtils.isNamespaceDefined(definition, faultNS))
70
		if (WsdlUtils.isNamespaceDefined(definition, faultNS))
71
	    return;
71
			return;
72
	definition.addNamespace("wsrf-bf", faultNS);
72
		definition.addNamespace("wsrf-bf", faultNS);
73
    }
73
	}
74
74
75
    private Input prepareOperationInput()
75
	private Input prepareOperationInput()
76
    {
76
	{
77
	Message inputMessage = prepareInputMessage();
77
		Message inputMessage = prepareInputMessage();
78
78
79
	Input input = WSDLFactory.eINSTANCE.createInput();
79
		Input input = WSDLFactory.eINSTANCE.createInput();
80
	input.setName("FoodRequest");
80
		input.setName("FoodRequest");
81
	input.setEnclosingDefinition(definition);
81
		input.setEnclosingDefinition(definition);
82
	input.setMessage(inputMessage);
82
		input.setMessage(inputMessage);
83
	return input;
83
		return input;
84
    }
84
	}
85
85
86
    private Output prepareOperationOutput()
86
	private Output prepareOperationOutput()
87
    {
87
	{
88
	Message outputMessage = prepareOutputMessage();
88
		Message outputMessage = prepareOutputMessage();
89
89
90
	Output output = WSDLFactory.eINSTANCE.createOutput();
90
		Output output = WSDLFactory.eINSTANCE.createOutput();
91
	output.setName("FoodResponse");
91
		output.setName("FoodResponse");
92
	output.setEnclosingDefinition(definition);
92
		output.setEnclosingDefinition(definition);
93
	output.setMessage(outputMessage);
93
		output.setMessage(outputMessage);
94
	return output;
94
		return output;
95
    }
95
	}
96
96
97
    private Fault prepareOperationFault()
97
	private Fault prepareOperationFault()
98
    {
98
	{
99
	Fault fault = WSDLFactory.eINSTANCE.createFault();
99
		Fault fault = WSDLFactory.eINSTANCE.createFault();
100
	fault.setName("FoodFault");
100
		fault.setName("FoodFault");
101
	fault.setEnclosingDefinition(definition);
101
		fault.setEnclosingDefinition(definition);
102
	Message faultMessage = prepareFaultMessage();
102
		Message faultMessage = prepareFaultMessage();
103
	fault.setMessage(faultMessage);
103
		fault.setMessage(faultMessage);
104
	return fault;
104
		return fault;
105
    }
105
	}
106
106
107
    private Message prepareInputMessage()
107
	private Message prepareInputMessage()
108
    {
108
	{
109
	XSDElementDeclaration inputParamHolderElement = TestUtils
109
		XSDElementDeclaration inputParamHolderElement = TestUtils
110
		.createNewProperty();
110
				.createNewProperty();
111
	return prepareMessage("FoodRequest", inputParamHolderElement);
111
		return prepareMessage("FoodRequest", inputParamHolderElement);
112
    }
112
	}
113
113
114
    private Message prepareOutputMessage()
114
	private Message prepareOutputMessage()
115
    {
115
	{
116
	XSDElementDeclaration outputParamHolderElement = TestUtils
116
		XSDElementDeclaration outputParamHolderElement = TestUtils
117
		.createNewProperty();
117
				.createNewProperty();
118
	return prepareMessage("FoodResponse", outputParamHolderElement);
118
		return prepareMessage("FoodResponse", outputParamHolderElement);
119
    }
119
	}
120
120
121
    private Message prepareFaultMessage()
121
	private Message prepareFaultMessage()
122
    {
122
	{
123
	XSDElementDeclaration faultElement = prepareFaultElement();
123
		XSDElementDeclaration faultElement = prepareFaultElement();
124
	return prepareMessage("FoodFault", faultElement);
124
		return prepareMessage("FoodFault", faultElement);
125
    }
125
	}
126
126
127
    private Message prepareMessage(String name,
127
	private Message prepareMessage(String name,
128
	    XSDElementDeclaration elementDeclaration)
128
			XSDElementDeclaration elementDeclaration)
129
    {
129
	{
130
130
131
	Part part = WSDLFactory.eINSTANCE.createPart();
131
		Part part = WSDLFactory.eINSTANCE.createPart();
132
	part.setName(name);
132
		part.setName(name);
133
	part.setElementName(new QName(elementDeclaration.getTargetNamespace(),
133
		part.setElementName(new QName(elementDeclaration.getTargetNamespace(),
134
		elementDeclaration.getName()));
134
				elementDeclaration.getName()));
135
	part.setEnclosingDefinition(definition);
135
		part.setEnclosingDefinition(definition);
136
	((PartImpl) part).reconcileReferences(false);
136
		((PartImpl) part).reconcileReferences(false);
137
137
138
	Message message = WSDLFactory.eINSTANCE.createMessage();
138
		Message message = WSDLFactory.eINSTANCE.createMessage();
139
	message.setQName(new QName(definition.getTargetNamespace(), name));
139
		message.setQName(new QName(definition.getTargetNamespace(), name));
140
	message.setEnclosingDefinition(definition);
140
		message.setEnclosingDefinition(definition);
141
	message.addPart(part);
141
		message.addPart(part);
142
	definition.addMessage(message);
142
		definition.addMessage(message);
143
143
144
	return message;
144
		return message;
145
    }
145
	}
146
146
147
    private XSDElementDeclaration prepareFaultElement()
147
	private XSDElementDeclaration prepareFaultElement()
148
    {
148
	{
149
	XSDElementDeclaration faultElement = XSDFactory.eINSTANCE
149
		XSDElementDeclaration faultElement = XSDFactory.eINSTANCE
150
		.createXSDElementDeclaration();
150
				.createXSDElementDeclaration();
151
	faultElement.setName("FoodFault");
151
		faultElement.setName("FoodFault");
152
	typesSchema.getContents().add(faultElement);
152
		typesSchema.getContents().add(faultElement);
153
153
154
	XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE
154
		XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE
155
		.createXSDComplexTypeDefinition();
155
				.createXSDComplexTypeDefinition();
156
	complexTypeDefinition
156
		complexTypeDefinition
157
		.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
157
				.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
158
	XSDSimpleTypeDefinition simpleTypeDef = XSDFactory.eINSTANCE
158
		XSDSimpleTypeDefinition simpleTypeDef = XSDFactory.eINSTANCE
159
		.createXSDSimpleTypeDefinition();
159
				.createXSDSimpleTypeDefinition();
160
	simpleTypeDef.setName("BaseFaultType");
160
		simpleTypeDef.setName("BaseFaultType");
161
	simpleTypeDef
161
		simpleTypeDef
162
		.setTargetNamespace("http://docs.oasis-open.org/wsrf/bf-2");
162
				.setTargetNamespace("http://docs.oasis-open.org/wsrf/bf-2");
163
	complexTypeDefinition.setBaseTypeDefinition(simpleTypeDef);
163
		complexTypeDefinition.setBaseTypeDefinition(simpleTypeDef);
164
164
165
	faultElement.setAnonymousTypeDefinition(complexTypeDefinition);
165
		faultElement.setAnonymousTypeDefinition(complexTypeDefinition);
166
	return faultElement;
166
		return faultElement;
167
    }
167
	}
168
168
169
}
169
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/operation/NewTestException.java (-60 / +60 lines)
Lines 31-97 Link Here
31
31
32
public class NewTestException
32
public class NewTestException
33
{
33
{
34
    private Definition _definition;
34
	private Definition _definition;
35
35
36
    private Operation _operation;
36
	private Operation _operation;
37
37
38
    public NewTestException(Definition definition, Operation operation)
38
	public NewTestException(Definition definition, Operation operation)
39
    {
39
	{
40
	_definition = definition;
40
		_definition = definition;
41
	_operation = operation;
41
		_operation = operation;
42
    }
42
	}
43
43
44
    public Fault getFault()
44
	public Fault getFault()
45
    {
45
	{
46
	return createBaseFaultFault();
46
		return createBaseFaultFault();
47
    }
47
	}
48
48
49
    private Fault createBaseFaultFault()
49
	private Fault createBaseFaultFault()
50
    {
50
	{
51
	Fault fault = WSDLFactory.eINSTANCE.createFault();
51
		Fault fault = WSDLFactory.eINSTANCE.createFault();
52
	fault.setName(_operation.getName() + "Fault");
52
		fault.setName(_operation.getName() + "Fault");
53
	fault.setEnclosingDefinition(_definition);
53
		fault.setEnclosingDefinition(_definition);
54
54
55
	Message faultMessage = WSDLFactory.eINSTANCE.createMessage();
55
		Message faultMessage = WSDLFactory.eINSTANCE.createMessage();
56
	faultMessage.setQName(new QName(_definition.getTargetNamespace(),
56
		faultMessage.setQName(new QName(_definition.getTargetNamespace(),
57
		_operation.getName() + "Fault"));
57
				_operation.getName() + "Fault"));
58
	faultMessage.setEnclosingDefinition(_definition);
58
		faultMessage.setEnclosingDefinition(_definition);
59
59
60
	Part faultPart = WSDLFactory.eINSTANCE.createPart();
60
		Part faultPart = WSDLFactory.eINSTANCE.createPart();
61
	faultPart.setName(_operation.getName() + "Fault");
61
		faultPart.setName(_operation.getName() + "Fault");
62
	faultPart.setEnclosingDefinition(_definition);
62
		faultPart.setEnclosingDefinition(_definition);
63
	XSDElementDeclaration faultElement = createBaseFaultElement();
63
		XSDElementDeclaration faultElement = createBaseFaultElement();
64
	faultPart.setElementDeclaration(faultElement);
64
		faultPart.setElementDeclaration(faultElement);
65
65
66
	faultMessage.addPart(faultPart);
66
		faultMessage.addPart(faultPart);
67
67
68
	fault.setEMessage(faultMessage);
68
		fault.setEMessage(faultMessage);
69
69
70
	return fault;
70
		return fault;
71
    }
71
	}
72
72
73
    private XSDElementDeclaration createBaseFaultElement()
73
	private XSDElementDeclaration createBaseFaultElement()
74
    {
74
	{
75
	XSDSchema typesSchema = WsdlUtils.getSchema(_definition, _definition
75
		XSDSchema typesSchema = WsdlUtils.getSchema(_definition, _definition
76
		.getTargetNamespace());
76
				.getTargetNamespace());
77
77
78
	XSDElementDeclaration faultElement = XSDFactory.eINSTANCE
78
		XSDElementDeclaration faultElement = XSDFactory.eINSTANCE
79
		.createXSDElementDeclaration();
79
				.createXSDElementDeclaration();
80
	faultElement.setName(_operation.getName() + "Fault");
80
		faultElement.setName(_operation.getName() + "Fault");
81
	typesSchema.getContents().add(faultElement);
81
		typesSchema.getContents().add(faultElement);
82
82
83
	XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE
83
		XSDComplexTypeDefinition complexTypeDefinition = XSDFactory.eINSTANCE
84
		.createXSDComplexTypeDefinition();
84
				.createXSDComplexTypeDefinition();
85
	complexTypeDefinition
85
		complexTypeDefinition
86
		.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
86
				.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
87
	XSDSimpleTypeDefinition simpleTypeDef = XSDFactory.eINSTANCE
87
		XSDSimpleTypeDefinition simpleTypeDef = XSDFactory.eINSTANCE
88
		.createXSDSimpleTypeDefinition();
88
				.createXSDSimpleTypeDefinition();
89
	simpleTypeDef.setName("BaseFaultType");
89
		simpleTypeDef.setName("BaseFaultType");
90
	simpleTypeDef.setTargetNamespace(WsdmConstants.WSBF_NS);
90
		simpleTypeDef.setTargetNamespace(WsdmConstants.WSBF_NS);
91
	complexTypeDefinition.setBaseTypeDefinition(simpleTypeDef);
91
		complexTypeDefinition.setBaseTypeDefinition(simpleTypeDef);
92
92
93
	faultElement.setAnonymousTypeDefinition(complexTypeDefinition);
93
		faultElement.setAnonymousTypeDefinition(complexTypeDefinition);
94
	return faultElement;
94
		return faultElement;
95
    }
95
	}
96
96
97
}
97
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/ChangePropertyTypeCommandTest.java (-60 / +60 lines)
Lines 28-94 Link Here
28
 */
28
 */
29
public class ChangePropertyTypeCommandTest extends PropertyCommandTestModel
29
public class ChangePropertyTypeCommandTest extends PropertyCommandTestModel
30
{
30
{
31
    /**
31
	/**
32
         * Constructor for ChangePropertyTypeCommandTest.
32
	 * Constructor for ChangePropertyTypeCommandTest.
33
         * 
33
	 * 
34
         * @param name
34
	 * @param name
35
         */
35
	 */
36
    public ChangePropertyTypeCommandTest(String name)
36
	public ChangePropertyTypeCommandTest(String name)
37
    {
37
	{
38
	super(name);
38
		super(name);
39
    }
39
	}
40
40
41
    /**
41
	/**
42
         * Returns the JUnit test suite that implements the
42
	 * Returns the JUnit test suite that implements the
43
         * <b>ChangePropertyTypeCommandTest</b> definition.
43
	 * <b>ChangePropertyTypeCommandTest</b> definition.
44
         */
44
	 */
45
    public static Test suite()
45
	public static Test suite()
46
    {
46
	{
47
	HyadesTestSuite changePropertyTypeCommandTest = new HyadesTestSuite(
47
		HyadesTestSuite changePropertyTypeCommandTest = new HyadesTestSuite(
48
		"ChangePropertyTypeCommandTest");
48
				"ChangePropertyTypeCommandTest");
49
	changePropertyTypeCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
49
		changePropertyTypeCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
50
		.setId("C8E89291F2E4762CF6038DB00FEF11DB");
50
				.setId("C8E89291F2E4762CF6038DB00FEF11DB");
51
51
52
	changePropertyTypeCommandTest
52
		changePropertyTypeCommandTest
53
		.addTest(new ChangePropertyTypeCommandTest(
53
				.addTest(new ChangePropertyTypeCommandTest(
54
			"testChangePropertyType"));
54
						"testChangePropertyType"));
55
55
56
	return changePropertyTypeCommandTest;
56
		return changePropertyTypeCommandTest;
57
    }
57
	}
58
58
59
    /**
59
	/**
60
         * @see junit.framework.TestCase#setUp()
60
	 * @see junit.framework.TestCase#setUp()
61
         */
61
	 */
62
    protected void setUp() throws Exception
62
	protected void setUp() throws Exception
63
    {
63
	{
64
	super.setUp();
64
		super.setUp();
65
    }
65
	}
66
66
67
    /**
67
	/**
68
         * @see junit.framework.TestCase#tearDown()
68
	 * @see junit.framework.TestCase#tearDown()
69
         */
69
	 */
70
    protected void tearDown() throws Exception
70
	protected void tearDown() throws Exception
71
    {
71
	{
72
    }
72
	}
73
73
74
    /**
74
	/**
75
         * testChangePropertyType
75
	 * testChangePropertyType
76
         * 
76
	 * 
77
         * @throws Exception
77
	 * @throws Exception
78
         */
78
	 */
79
    public void testChangePropertyType() throws Exception
79
	public void testChangePropertyType() throws Exception
80
    {
80
	{
81
	Property property = (Property) capability.getProperties().get(0);
81
		Property property = (Property) capability.getProperties().get(0);
82
	DataType newDataType = TestUtils.getDataType("int");
82
		DataType newDataType = TestUtils.getDataType("int");
83
	String newType = newDataType.getTypeName();
83
		String newType = newDataType.getTypeName();
84
84
85
	ChangePropertyTypeCommand command = new ChangePropertyTypeCommand(
85
		ChangePropertyTypeCommand command = new ChangePropertyTypeCommand(
86
		capabilityDomain, property, newDataType);
86
				capabilityDomain, property, newDataType);
87
	command.execute();
87
		command.execute();
88
88
89
	String changedType = XsdUtils.getType(property.getElement());
89
		String changedType = XsdUtils.getType(property.getElement());
90
	assertEquals(newType, changedType);
90
		assertEquals(newType, changedType);
91
91
92
    }
92
	}
93
93
94
}
94
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/ChangePropertyNameCommandTest.java (-73 / +73 lines)
Lines 27-104 Link Here
27
 */
27
 */
28
public class ChangePropertyNameCommandTest extends PropertyCommandTestModel
28
public class ChangePropertyNameCommandTest extends PropertyCommandTestModel
29
{
29
{
30
    /**
30
	/**
31
         * Constructor for ChangePropertyNameCommandTest.
31
	 * Constructor for ChangePropertyNameCommandTest.
32
         * 
32
	 * 
33
         * @param name
33
	 * @param name
34
         */
34
	 */
35
    public ChangePropertyNameCommandTest(String name)
35
	public ChangePropertyNameCommandTest(String name)
36
    {
36
	{
37
	super(name);
37
		super(name);
38
    }
38
	}
39
39
40
    /**
40
	/**
41
         * Returns the JUnit test suite that implements the
41
	 * Returns the JUnit test suite that implements the
42
         * <b>ChangePropertyNameCommandTest</b> definition.
42
	 * <b>ChangePropertyNameCommandTest</b> definition.
43
         */
43
	 */
44
    public static Test suite()
44
	public static Test suite()
45
    {
45
	{
46
	HyadesTestSuite changePropertyNameCommandTest = new HyadesTestSuite(
46
		HyadesTestSuite changePropertyNameCommandTest = new HyadesTestSuite(
47
		"ChangePropertyNameCommandTest");
47
				"ChangePropertyNameCommandTest");
48
	changePropertyNameCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
48
		changePropertyNameCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
49
		.setId("C8E89291F2E4762CE093B7B00FEB11DB");
49
				.setId("C8E89291F2E4762CE093B7B00FEB11DB");
50
50
51
	changePropertyNameCommandTest
51
		changePropertyNameCommandTest
52
		.addTest(new ChangePropertyNameCommandTest(
52
				.addTest(new ChangePropertyNameCommandTest(
53
			"testChangePropertyName"));
53
						"testChangePropertyName"));
54
54
55
	return changePropertyNameCommandTest;
55
		return changePropertyNameCommandTest;
56
    }
56
	}
57
57
58
    /**
58
	/**
59
         * @see junit.framework.TestCase#setUp()
59
	 * @see junit.framework.TestCase#setUp()
60
         */
60
	 */
61
    protected void setUp() throws Exception
61
	protected void setUp() throws Exception
62
    {
62
	{
63
	super.setUp();
63
		super.setUp();
64
    }
64
	}
65
65
66
    /**
66
	/**
67
         * @see junit.framework.TestCase#tearDown()
67
	 * @see junit.framework.TestCase#tearDown()
68
         */
68
	 */
69
    protected void tearDown() throws Exception
69
	protected void tearDown() throws Exception
70
    {
70
	{
71
    }
71
	}
72
72
73
    /**
73
	/**
74
         * testChangePropertyName
74
	 * testChangePropertyName
75
         * 
75
	 * 
76
         * @throws Exception
76
	 * @throws Exception
77
         */
77
	 */
78
    public void testChangePropertyName() throws Exception
78
	public void testChangePropertyName() throws Exception
79
    {
79
	{
80
	Property property = (Property) capability.getProperties().get(0);
80
		Property property = (Property) capability.getProperties().get(0);
81
	XSDElementDeclaration propertyRef = getPropertyRef(property
81
		XSDElementDeclaration propertyRef = getPropertyRef(property
82
		.getElement());
82
				.getElement());
83
	String oldName = new String(XsdUtils.getName(property.getElement()));
83
		String oldName = new String(XsdUtils.getName(property.getElement()));
84
	String newName = "newProperty";
84
		String newName = "newProperty";
85
85
86
	ChangePropertyNameCommand command = new ChangePropertyNameCommand(
86
		ChangePropertyNameCommand command = new ChangePropertyNameCommand(
87
		capabilityDomain, property, newName);
87
				capabilityDomain, property, newName);
88
	command.execute();
88
		command.execute();
89
89
90
	XSDElementDeclaration oldProperty = XsdUtils
90
		XSDElementDeclaration oldProperty = XsdUtils
91
		.getXSDElementDeclarationOfName(propSchema, oldName);
91
				.getXSDElementDeclarationOfName(propSchema, oldName);
92
	assertNull(oldProperty);
92
		assertNull(oldProperty);
93
93
94
	XSDElementDeclaration changedProperty = XsdUtils
94
		XSDElementDeclaration changedProperty = XsdUtils
95
		.getXSDElementDeclarationOfName(propSchema, newName);
95
				.getXSDElementDeclarationOfName(propSchema, newName);
96
	assertNotNull(changedProperty);
96
		assertNotNull(changedProperty);
97
	assertEquals(changedProperty.getName(), newName);
97
		assertEquals(changedProperty.getName(), newName);
98
98
99
	XSDElementDeclaration changedPropertyResolvedElement = propertyRef
99
		XSDElementDeclaration changedPropertyResolvedElement = propertyRef
100
		.getResolvedElementDeclaration();
100
				.getResolvedElementDeclaration();
101
	assertEquals(changedProperty, changedPropertyResolvedElement);
101
		assertEquals(changedProperty, changedPropertyResolvedElement);
102
102
103
    }
103
	}
104
}
104
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/ChangeModifiabilityCommandTest.java (-73 / +72 lines)
Lines 15-21 Link Here
15
15
16
import junit.framework.Test;
16
import junit.framework.Test;
17
17
18
import org.eclipse.emf.ecore.xml.type.internal.QName;
19
import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
18
import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
20
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
19
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
21
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangeModifiabilityCommand;
20
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangeModifiabilityCommand;
Lines 32-108 Link Here
32
 */
31
 */
33
public class ChangeModifiabilityCommandTest extends PropertyCommandTestModel
32
public class ChangeModifiabilityCommandTest extends PropertyCommandTestModel
34
{
33
{
35
    /**
34
	/**
36
         * Constructor for ChangeModifiabilityCommandTest.
35
	 * Constructor for ChangeModifiabilityCommandTest.
37
         * 
36
	 * 
38
         * @param name
37
	 * @param name
39
         */
38
	 */
40
    public ChangeModifiabilityCommandTest(String name)
39
	public ChangeModifiabilityCommandTest(String name)
41
    {
40
	{
42
	super(name);
41
		super(name);
43
    }
42
	}
44
43
45
    /**
44
	/**
46
         * Returns the JUnit test suite that implements the
45
	 * Returns the JUnit test suite that implements the
47
         * <b>ChangeModifiabilityCommandTest</b> definition.
46
	 * <b>ChangeModifiabilityCommandTest</b> definition.
48
         */
47
	 */
49
    public static Test suite()
48
	public static Test suite()
50
    {
49
	{
51
	HyadesTestSuite changeModifiabilityCommandTest = new HyadesTestSuite(
50
		HyadesTestSuite changeModifiabilityCommandTest = new HyadesTestSuite(
52
		"ChangeModifiabilityCommandTest");
51
				"ChangeModifiabilityCommandTest");
53
	changeModifiabilityCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
52
		changeModifiabilityCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
54
		.setId("C8E89291F2E4762C34F48DF00FF811DB");
53
				.setId("C8E89291F2E4762C34F48DF00FF811DB");
55
54
56
	changeModifiabilityCommandTest
55
		changeModifiabilityCommandTest
57
		.addTest(new ChangeModifiabilityCommandTest(
56
				.addTest(new ChangeModifiabilityCommandTest(
58
			"testChangeModifiability"));
57
						"testChangeModifiability"));
59
58
60
	return changeModifiabilityCommandTest;
59
		return changeModifiabilityCommandTest;
61
    }
60
	}
62
61
63
    /**
62
	/**
64
         * @see junit.framework.TestCase#setUp()
63
	 * @see junit.framework.TestCase#setUp()
65
         */
64
	 */
66
    protected void setUp() throws Exception
65
	protected void setUp() throws Exception
67
    {
66
	{
68
	super.setUp();
67
		super.setUp();
69
    }
68
	}
70
69
71
    /**
70
	/**
72
         * @see junit.framework.TestCase#tearDown()
71
	 * @see junit.framework.TestCase#tearDown()
73
         */
72
	 */
74
    protected void tearDown() throws Exception
73
	protected void tearDown() throws Exception
75
    {
74
	{
76
    }
75
	}
77
76
78
    /**
77
	/**
79
         * testChangeModifiability
78
	 * testChangeModifiability
80
         * 
79
	 * 
81
         * @throws Exception
80
	 * @throws Exception
82
         */
81
	 */
83
    public void testChangeModifiability() throws Exception
82
	public void testChangeModifiability() throws Exception
84
    {
83
	{
85
	List properties = capability.getProperties();
84
		List properties = capability.getProperties();
86
	assertNotNull(properties);
85
		assertNotNull(properties);
87
	assertTrue(properties.size() > 0);
86
		assertTrue(properties.size() > 0);
88
	Object object = properties.get(0);
87
		Object object = properties.get(0);
89
	assertTrue(object instanceof Property);
88
		assertTrue(object instanceof Property);
90
	Property property = (Property) object;
89
		Property property = (Property) object;
91
	PropertyType metadata = property.getMetaData();
90
		PropertyType metadata = property.getMetaData();
92
	assertNotNull(metadata.getModifiability());
91
		assertNotNull(metadata.getModifiability());
93
	assertEquals(MetaDataUtils.READ_ONLY, metadata.getModifiability()
92
		assertEquals(MetaDataUtils.READ_ONLY, metadata.getModifiability()
94
		.getLiteral());
93
				.getLiteral());
95
	QName propName = (QName) metadata.getName();
94
		String propName = metadata.getName();
96
95
97
	ChangeModifiabilityCommand command = new ChangeModifiabilityCommand(
96
		ChangeModifiabilityCommand command = new ChangeModifiabilityCommand(
98
		capabilityDomain, property, MetaDataUtils.WRITABLE);
97
				capabilityDomain, property, MetaDataUtils.WRITABLE);
99
	command.execute();
98
		command.execute();
100
99
101
	PropertyType changedMetadata = TestUtils.getPropertyType(capability,
100
		PropertyType changedMetadata = TestUtils.getPropertyType(capability,
102
		propName);
101
				propName);
103
	assertNotNull(changedMetadata);
102
		assertNotNull(changedMetadata);
104
	assertEquals(MetaDataUtils.WRITABLE, changedMetadata.getModifiability()
103
		assertEquals(MetaDataUtils.WRITABLE, changedMetadata.getModifiability()
105
		.getLiteral());
104
				.getLiteral());
106
105
107
    }
106
	}
108
}
107
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/RemovePropertyCommandTest.java (-77 / +77 lines)
Lines 29-111 Link Here
29
 */
29
 */
30
public class RemovePropertyCommandTest extends PropertyCommandTestModel
30
public class RemovePropertyCommandTest extends PropertyCommandTestModel
31
{
31
{
32
    /**
32
	/**
33
         * Constructor for RemovePropertyCommandTest.
33
	 * Constructor for RemovePropertyCommandTest.
34
         * 
34
	 * 
35
         * @param name
35
	 * @param name
36
         */
36
	 */
37
    public RemovePropertyCommandTest(String name)
37
	public RemovePropertyCommandTest(String name)
38
    {
38
	{
39
	super(name);
39
		super(name);
40
    }
40
	}
41
41
42
    /**
42
	/**
43
         * Returns the JUnit test suite that implements the
43
	 * Returns the JUnit test suite that implements the
44
         * <b>RemovePropertyCommandTest</b> definition.
44
	 * <b>RemovePropertyCommandTest</b> definition.
45
         */
45
	 */
46
    public static Test suite()
46
	public static Test suite()
47
    {
47
	{
48
	HyadesTestSuite removePropertyCommandTest = new HyadesTestSuite(
48
		HyadesTestSuite removePropertyCommandTest = new HyadesTestSuite(
49
		"RemovePropertyCommandTest");
49
				"RemovePropertyCommandTest");
50
	removePropertyCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
50
		removePropertyCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
51
		.setId("C8E89291F2E4762CC48CE9400FE811DB");
51
				.setId("C8E89291F2E4762CC48CE9400FE811DB");
52
52
53
	removePropertyCommandTest.addTest(new RemovePropertyCommandTest(
53
		removePropertyCommandTest.addTest(new RemovePropertyCommandTest(
54
		"testRemoveProperty"));
54
				"testRemoveProperty"));
55
55
56
	return removePropertyCommandTest;
56
		return removePropertyCommandTest;
57
    }
57
	}
58
58
59
    /**
59
	/**
60
         * @see junit.framework.TestCase#setUp()
60
	 * @see junit.framework.TestCase#setUp()
61
         */
61
	 */
62
    protected void setUp() throws Exception
62
	protected void setUp() throws Exception
63
    {
63
	{
64
	super.setUp();
64
		super.setUp();
65
    }
65
	}
66
66
67
    /**
67
	/**
68
         * @see junit.framework.TestCase#tearDown()
68
	 * @see junit.framework.TestCase#tearDown()
69
         */
69
	 */
70
    protected void tearDown() throws Exception
70
	protected void tearDown() throws Exception
71
    {
71
	{
72
    }
72
	}
73
73
74
    /**
74
	/**
75
         * testRemoveProperty
75
	 * testRemoveProperty
76
         * 
76
	 * 
77
         * @throws Exception
77
	 * @throws Exception
78
         */
78
	 */
79
    public void testRemoveProperty() throws Exception
79
	public void testRemoveProperty() throws Exception
80
    {
80
	{
81
	XSDElementDeclaration[] oldWSDLProperties = CapUtils
81
		XSDElementDeclaration[] oldWSDLProperties = CapUtils
82
		.getResolvedProperties(definition, resourcePropertyElement);
82
				.getResolvedProperties(definition, resourcePropertyElement);
83
	XSDElementDeclaration[] oldXSDProperties = TestUtils
83
		XSDElementDeclaration[] oldXSDProperties = TestUtils
84
		.getXSDElementDeclarations(propSchema);
84
				.getXSDElementDeclarations(propSchema);
85
	Property property = (Property) capability.getProperties().get(0);
85
		Property property = (Property) capability.getProperties().get(0);
86
	String propName = new String(XsdUtils.getName(property.getElement()));
86
		String propName = new String(XsdUtils.getName(property.getElement()));
87
87
88
	RemovePropertyCommand command = new RemovePropertyCommand(
88
		RemovePropertyCommand command = new RemovePropertyCommand(
89
		capabilityDomain, property);
89
				capabilityDomain, property);
90
	command.execute();
90
		command.execute();
91
91
92
	XSDElementDeclaration[] newWSDLProperties = CapUtils
92
		XSDElementDeclaration[] newWSDLProperties = CapUtils
93
		.getResolvedProperties(definition, resourcePropertyElement);
93
				.getResolvedProperties(definition, resourcePropertyElement);
94
	XSDElementDeclaration[] newXSDProperties = TestUtils
94
		XSDElementDeclaration[] newXSDProperties = TestUtils
95
		.getXSDElementDeclarations(propSchema);
95
				.getXSDElementDeclarations(propSchema);
96
96
97
	assertNotNull(definition);
97
		assertNotNull(definition);
98
	assertNotNull(resourcePropertyElement);
98
		assertNotNull(resourcePropertyElement);
99
	assertNotNull(propSchema);
99
		assertNotNull(propSchema);
100
	assertTrue(newWSDLProperties.length == oldWSDLProperties.length - 1);
100
		assertTrue(newWSDLProperties.length == oldWSDLProperties.length - 1);
101
	assertTrue(newXSDProperties.length == oldXSDProperties.length - 1);
101
		assertTrue(newXSDProperties.length == oldXSDProperties.length - 1);
102
102
103
	XSDElementDeclaration deletedProp = XsdUtils
103
		XSDElementDeclaration deletedProp = XsdUtils
104
		.getXSDElementDeclarationOfName(propSchema, propName);
104
				.getXSDElementDeclarationOfName(propSchema, propName);
105
	assertNull(deletedProp);
105
		assertNull(deletedProp);
106
	XSDElementDeclaration propRef = getPropertyRef(property.getElement());
106
		XSDElementDeclaration propRef = getPropertyRef(property.getElement());
107
	assertNull(propRef);
107
		assertNull(propRef);
108
108
109
    }
109
	}
110
110
111
}
111
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/ChangePropertyNameMetaDataCommandTest.java (-74 / +71 lines)
Lines 15-21 Link Here
15
15
16
import junit.framework.Test;
16
import junit.framework.Test;
17
17
18
import org.eclipse.emf.ecore.xml.type.internal.QName;
19
import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
18
import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
20
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
19
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
21
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangePropertyNameMetaDataCommand;
20
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangePropertyNameMetaDataCommand;
Lines 30-109 Link Here
30
 * 
29
 * 
31
 */
30
 */
32
public class ChangePropertyNameMetaDataCommandTest extends
31
public class ChangePropertyNameMetaDataCommandTest extends
33
	PropertyCommandTestModel
32
		PropertyCommandTestModel
34
{
33
{
35
    /**
34
	/**
36
         * Constructor for ChangePropertyNameMetaDataCommandTest.
35
	 * Constructor for ChangePropertyNameMetaDataCommandTest.
37
         * 
36
	 * 
38
         * @param name
37
	 * @param name
39
         */
38
	 */
40
    public ChangePropertyNameMetaDataCommandTest(String name)
39
	public ChangePropertyNameMetaDataCommandTest(String name)
41
    {
40
	{
42
	super(name);
41
		super(name);
43
    }
42
	}
44
43
45
    /**
44
	/**
46
         * Returns the JUnit test suite that implements the
45
	 * Returns the JUnit test suite that implements the
47
         * <b>ChangePropertyNameMetaDataCommandTest</b> definition.
46
	 * <b>ChangePropertyNameMetaDataCommandTest</b> definition.
48
         */
47
	 */
49
    public static Test suite()
48
	public static Test suite()
50
    {
49
	{
51
	HyadesTestSuite changePropertyNameMetaDataCommandTest = new HyadesTestSuite(
50
		HyadesTestSuite changePropertyNameMetaDataCommandTest = new HyadesTestSuite(
52
		"ChangePropertyNameMetaDataCommandTest");
51
				"ChangePropertyNameMetaDataCommandTest");
53
	changePropertyNameMetaDataCommandTest.setArbiter(
52
		changePropertyNameMetaDataCommandTest.setArbiter(
54
		DefaultTestArbiter.INSTANCE).setId(
53
				DefaultTestArbiter.INSTANCE).setId(
55
		"C8E89291F2E4762CA3FD9CC00FF611DB");
54
				"C8E89291F2E4762CA3FD9CC00FF611DB");
56
55
57
	changePropertyNameMetaDataCommandTest
56
		changePropertyNameMetaDataCommandTest
58
		.addTest(new ChangePropertyNameMetaDataCommandTest(
57
				.addTest(new ChangePropertyNameMetaDataCommandTest(
59
			"testChangePropertyNameMetaData"));
58
						"testChangePropertyNameMetaData"));
60
59
61
	return changePropertyNameMetaDataCommandTest;
60
		return changePropertyNameMetaDataCommandTest;
62
    }
61
	}
63
62
64
    /**
63
	/**
65
         * @see junit.framework.TestCase#setUp()
64
	 * @see junit.framework.TestCase#setUp()
66
         */
65
	 */
67
    protected void setUp() throws Exception
66
	protected void setUp() throws Exception
68
    {
67
	{
69
	super.setUp();
68
		super.setUp();
70
    }
69
	}
71
70
72
    /**
71
	/**
73
         * @see junit.framework.TestCase#tearDown()
72
	 * @see junit.framework.TestCase#tearDown()
74
         */
73
	 */
75
    protected void tearDown() throws Exception
74
	protected void tearDown() throws Exception
76
    {
75
	{
77
    }
76
	}
78
77
79
    /**
78
	/**
80
         * testChangePropertyNameMetaData
79
	 * testChangePropertyNameMetaData
81
         * 
80
	 * 
82
         * @throws Exception
81
	 * @throws Exception
83
         */
82
	 */
84
    public void testChangePropertyNameMetaData() throws Exception
83
	public void testChangePropertyNameMetaData() throws Exception
85
    {
84
	{
86
	List properties = capability.getProperties();
85
		List properties = capability.getProperties();
87
	assertNotNull(properties);
86
		assertNotNull(properties);
88
	assertTrue(properties.size() > 0);
87
		assertTrue(properties.size() > 0);
89
	Object object = properties.get(0);
88
		Object object = properties.get(0);
90
	assertTrue(object instanceof Property);
89
		assertTrue(object instanceof Property);
91
	Property property = (Property) object;
90
		Property property = (Property) object;
92
	PropertyType metadata = property.getMetaData();
91
		PropertyType metadata = property.getMetaData();
93
	assertNotNull(metadata.getName());
92
		assertNotNull(metadata.getName());
94
	QName propName = (QName) metadata.getName();
93
		String propQName = metadata.getName();
95
	QName oldPropName = new QName(propName.getNamespaceURI(), propName
94
		String oldPropQName = new String(propQName);
96
		.getLocalPart(), propName.getPrefix());
95
		String newPropertyName = "dummy";
97
	String newPropertyName = "dummy";
96
98
97
		ChangePropertyNameMetaDataCommand command = new ChangePropertyNameMetaDataCommand(
99
	ChangePropertyNameMetaDataCommand command = new ChangePropertyNameMetaDataCommand(
98
				capabilityDomain, property, newPropertyName);
100
		capabilityDomain, property, newPropertyName);
99
		command.execute();
101
	command.execute();
102
103
	assertNull(TestUtils.getPropertyType(capability, oldPropName
104
		.getLocalPart()));
105
	assertNotNull(TestUtils.getPropertyType(capability, newPropertyName));
106
100
107
    }
101
		assertNull(TestUtils.getPropertyType(capability, oldPropQName));
102
		assertNotNull(TestUtils.getPropertyType(capability, newPropertyName));
103
104
	}
108
105
109
}
106
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/PropertyCommandTestModel.java (-9 / +9 lines)
Lines 17-31 Link Here
17
17
18
public class PropertyCommandTestModel extends CapabilityTestModel
18
public class PropertyCommandTestModel extends CapabilityTestModel
19
{
19
{
20
    public PropertyCommandTestModel(String name)
20
	public PropertyCommandTestModel(String name)
21
    {
21
	{
22
	this(name, Activator.PLUGIN_ID + "/"
22
		this(name, Activator.PLUGIN_ID + "/"
23
		+ "testfiles/capability/command/property/AppServer.mcap");
23
				+ "testfiles/capability/command/property/AppServer.mcap");
24
    }
24
	}
25
25
26
    public PropertyCommandTestModel(String name, String CapabilityIFilePath)
26
	public PropertyCommandTestModel(String name, String CapabilityIFilePath)
27
    {
27
	{
28
	super(name, CapabilityIFilePath);
28
		super(name, CapabilityIFilePath);
29
    }
29
	}
30
30
31
}
31
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/AllPropertyCommandTest.java (-61 / +61 lines)
Lines 24-89 Link Here
24
 */
24
 */
25
public class AllPropertyCommandTest extends HyadesTestCase
25
public class AllPropertyCommandTest extends HyadesTestCase
26
{
26
{
27
    /**
27
	/**
28
         * Constructor for AllPropertyCommandTest.
28
	 * Constructor for AllPropertyCommandTest.
29
         * 
29
	 * 
30
         * @param name
30
	 * @param name
31
         */
31
	 */
32
    public AllPropertyCommandTest(String name)
32
	public AllPropertyCommandTest(String name)
33
    {
33
	{
34
	super(name);
34
		super(name);
35
    }
35
	}
36
36
37
    /**
37
	/**
38
         * Returns the JUnit test suite that implements the
38
	 * Returns the JUnit test suite that implements the
39
         * <b>AllPropertyCommandTest</b> definition.
39
	 * <b>AllPropertyCommandTest</b> definition.
40
         */
40
	 */
41
    public static Test suite()
41
	public static Test suite()
42
    {
42
	{
43
	HyadesTestSuite allPropertyCommandTest = new HyadesTestSuite(
43
		HyadesTestSuite allPropertyCommandTest = new HyadesTestSuite(
44
		"AllPropertyCommandTest");
44
				"AllPropertyCommandTest");
45
	allPropertyCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
45
		allPropertyCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
46
		"C8E89291F2E4762C427C86B00FEB11DB");
46
				"C8E89291F2E4762C427C86B00FEB11DB");
47
47
48
	allPropertyCommandTest.addTest(HyadesJUnitRunner
48
		allPropertyCommandTest.addTest(HyadesJUnitRunner
49
		.getTest(AddPropertyCommandTest.class));
49
				.getTest(AddPropertyCommandTest.class));
50
50
51
	allPropertyCommandTest.addTest(HyadesJUnitRunner
51
		allPropertyCommandTest.addTest(HyadesJUnitRunner
52
		.getTest(RemovePropertyCommandTest.class));
52
				.getTest(RemovePropertyCommandTest.class));
53
53
54
	allPropertyCommandTest.addTest(HyadesJUnitRunner
54
		allPropertyCommandTest.addTest(HyadesJUnitRunner
55
		.getTest(ChangePropertyNameCommandTest.class));
55
				.getTest(ChangePropertyNameCommandTest.class));
56
56
57
	allPropertyCommandTest.addTest(HyadesJUnitRunner
57
		allPropertyCommandTest.addTest(HyadesJUnitRunner
58
		.getTest(ChangePropertyTypeCommandTest.class));
58
				.getTest(ChangePropertyTypeCommandTest.class));
59
59
60
	allPropertyCommandTest.addTest(HyadesJUnitRunner
60
		allPropertyCommandTest.addTest(HyadesJUnitRunner
61
		.getTest(ChangePropertyCardinalityCommandTest.class));
61
				.getTest(ChangePropertyCardinalityCommandTest.class));
62
62
63
	allPropertyCommandTest.addTest(HyadesJUnitRunner
63
		allPropertyCommandTest.addTest(HyadesJUnitRunner
64
		.getTest(ChangePropertyNameMetaDataCommandTest.class));
64
				.getTest(ChangePropertyNameMetaDataCommandTest.class));
65
65
66
	allPropertyCommandTest.addTest(HyadesJUnitRunner
66
		allPropertyCommandTest.addTest(HyadesJUnitRunner
67
		.getTest(ChangeModifiabilityCommandTest.class));
67
				.getTest(ChangeModifiabilityCommandTest.class));
68
68
69
	allPropertyCommandTest.addTest(HyadesJUnitRunner
69
		allPropertyCommandTest.addTest(HyadesJUnitRunner
70
		.getTest(ChangeMutabilityCommandTest.class));
70
				.getTest(ChangeMutabilityCommandTest.class));
71
71
72
	return allPropertyCommandTest;
72
		return allPropertyCommandTest;
73
    }
73
	}
74
74
75
    /**
75
	/**
76
         * @see junit.framework.TestCase#setUp()
76
	 * @see junit.framework.TestCase#setUp()
77
         */
77
	 */
78
    protected void setUp() throws Exception
78
	protected void setUp() throws Exception
79
    {
79
	{
80
    }
80
	}
81
81
82
    /**
82
	/**
83
         * @see junit.framework.TestCase#tearDown()
83
	 * @see junit.framework.TestCase#tearDown()
84
         */
84
	 */
85
    protected void tearDown() throws Exception
85
	protected void tearDown() throws Exception
86
    {
86
	{
87
    }
87
	}
88
88
89
}
89
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/ChangePropertyCardinalityCommandTest.java (-68 / +68 lines)
Lines 26-100 Link Here
26
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/property/command/ChangePropertyCardinalityCommandTest.testsuite</i>.
26
 * <i>/org.eclipse.tptp.wsdm.tooling.editor.capability.test/junit/capability/property/command/ChangePropertyCardinalityCommandTest.testsuite</i>.
27
 */
27
 */
28
public class ChangePropertyCardinalityCommandTest extends
28
public class ChangePropertyCardinalityCommandTest extends
29
	PropertyCommandTestModel
29
		PropertyCommandTestModel
30
{
30
{
31
    /**
31
	/**
32
         * Constructor for ChangePropertyCardinalityCommandTest.
32
	 * Constructor for ChangePropertyCardinalityCommandTest.
33
         * 
33
	 * 
34
         * @param name
34
	 * @param name
35
         */
35
	 */
36
    public ChangePropertyCardinalityCommandTest(String name)
36
	public ChangePropertyCardinalityCommandTest(String name)
37
    {
37
	{
38
	super(name);
38
		super(name);
39
    }
39
	}
40
40
41
    /**
41
	/**
42
         * Returns the JUnit test suite that implements the
42
	 * Returns the JUnit test suite that implements the
43
         * <b>ChangePropertyCardinalityCommandTest</b> definition.
43
	 * <b>ChangePropertyCardinalityCommandTest</b> definition.
44
         */
44
	 */
45
    public static Test suite()
45
	public static Test suite()
46
    {
46
	{
47
	HyadesTestSuite changePropertyCardinalityCommandTest = new HyadesTestSuite(
47
		HyadesTestSuite changePropertyCardinalityCommandTest = new HyadesTestSuite(
48
		"ChangePropertyCardinalityCommandTest");
48
				"ChangePropertyCardinalityCommandTest");
49
	changePropertyCardinalityCommandTest.setArbiter(
49
		changePropertyCardinalityCommandTest.setArbiter(
50
		DefaultTestArbiter.INSTANCE).setId(
50
				DefaultTestArbiter.INSTANCE).setId(
51
		"C8E89291F2E4762CF90DC3A00FF311DB");
51
				"C8E89291F2E4762CF90DC3A00FF311DB");
52
52
53
	changePropertyCardinalityCommandTest
53
		changePropertyCardinalityCommandTest
54
		.addTest(new ChangePropertyCardinalityCommandTest(
54
				.addTest(new ChangePropertyCardinalityCommandTest(
55
			"testChangePropertyCardinality"));
55
						"testChangePropertyCardinality"));
56
56
57
	return changePropertyCardinalityCommandTest;
57
		return changePropertyCardinalityCommandTest;
58
    }
58
	}
59
59
60
    /**
60
	/**
61
         * @see junit.framework.TestCase#setUp()
61
	 * @see junit.framework.TestCase#setUp()
62
         */
62
	 */
63
    protected void setUp() throws Exception
63
	protected void setUp() throws Exception
64
    {
64
	{
65
	super.setUp();
65
		super.setUp();
66
    }
66
	}
67
67
68
    /**
68
	/**
69
         * @see junit.framework.TestCase#tearDown()
69
	 * @see junit.framework.TestCase#tearDown()
70
         */
70
	 */
71
    protected void tearDown() throws Exception
71
	protected void tearDown() throws Exception
72
    {
72
	{
73
    }
73
	}
74
74
75
    /**
75
	/**
76
         * testChangePropertyCardinality
76
	 * testChangePropertyCardinality
77
         * 
77
	 * 
78
         * @throws Exception
78
	 * @throws Exception
79
         */
79
	 */
80
    public void testChangePropertyCardinality() throws Exception
80
	public void testChangePropertyCardinality() throws Exception
81
    {
81
	{
82
	Property property = (Property) capability.getProperties().get(0);
82
		Property property = (Property) capability.getProperties().get(0);
83
	int minoccurs = 5;
83
		int minoccurs = 5;
84
	int maxoccurs = 10;
84
		int maxoccurs = 10;
85
85
86
	ChangePropertyCardinalityCommand command = new ChangePropertyCardinalityCommand(
86
		ChangePropertyCardinalityCommand command = new ChangePropertyCardinalityCommand(
87
		capabilityDomain, property, minoccurs, maxoccurs);
87
				capabilityDomain, property, minoccurs, maxoccurs);
88
	command.execute();
88
		command.execute();
89
89
90
	XSDElementDeclaration propertyRef = getPropertyRef(property
90
		XSDElementDeclaration propertyRef = getPropertyRef(property
91
		.getElement());
91
				.getElement());
92
	assertNotNull(propertyRef);
92
		assertNotNull(propertyRef);
93
	assertTrue(propertyRef.eContainer() instanceof XSDParticle);
93
		assertTrue(propertyRef.eContainer() instanceof XSDParticle);
94
	XSDParticle xsdParticle = (XSDParticle) propertyRef.eContainer();
94
		XSDParticle xsdParticle = (XSDParticle) propertyRef.eContainer();
95
	assertEquals(minoccurs, xsdParticle.getMinOccurs());
95
		assertEquals(minoccurs, xsdParticle.getMinOccurs());
96
	assertEquals(maxoccurs, xsdParticle.getMaxOccurs());
96
		assertEquals(maxoccurs, xsdParticle.getMaxOccurs());
97
97
98
    }
98
	}
99
99
100
}
100
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/ChangeMutabilityCommandTest.java (-72 / +71 lines)
Lines 15-21 Link Here
15
15
16
import junit.framework.Test;
16
import junit.framework.Test;
17
17
18
import org.eclipse.emf.ecore.xml.type.internal.QName;
19
import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
18
import org.eclipse.hyades.test.common.junit.DefaultTestArbiter;
20
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
19
import org.eclipse.hyades.test.common.junit.HyadesTestSuite;
21
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangeMutabilityCommand;
20
import org.eclipse.tptp.wsdm.tooling.editor.capability.command.property.internal.ChangeMutabilityCommand;
Lines 31-106 Link Here
31
 */
30
 */
32
public class ChangeMutabilityCommandTest extends PropertyCommandTestModel
31
public class ChangeMutabilityCommandTest extends PropertyCommandTestModel
33
{
32
{
34
    /**
33
	/**
35
         * Constructor for ChangeMutabilityCommandTest.
34
	 * Constructor for ChangeMutabilityCommandTest.
36
         * 
35
	 * 
37
         * @param name
36
	 * @param name
38
         */
37
	 */
39
    public ChangeMutabilityCommandTest(String name)
38
	public ChangeMutabilityCommandTest(String name)
40
    {
39
	{
41
	super(name);
40
		super(name);
42
    }
41
	}
43
42
44
    /**
43
	/**
45
         * Returns the JUnit test suite that implements the
44
	 * Returns the JUnit test suite that implements the
46
         * <b>ChangeMutabilityCommandTest</b> definition.
45
	 * <b>ChangeMutabilityCommandTest</b> definition.
47
         */
46
	 */
48
    public static Test suite()
47
	public static Test suite()
49
    {
48
	{
50
	HyadesTestSuite changeMutabilityCommandTest = new HyadesTestSuite(
49
		HyadesTestSuite changeMutabilityCommandTest = new HyadesTestSuite(
51
		"ChangeMutabilityCommandTest");
50
				"ChangeMutabilityCommandTest");
52
	changeMutabilityCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
51
		changeMutabilityCommandTest.setArbiter(DefaultTestArbiter.INSTANCE)
53
		.setId("C8E89291F2E4762C6FB72AF00FF911DB");
52
				.setId("C8E89291F2E4762C6FB72AF00FF911DB");
54
53
55
	changeMutabilityCommandTest.addTest(new ChangeMutabilityCommandTest(
54
		changeMutabilityCommandTest.addTest(new ChangeMutabilityCommandTest(
56
		"testChangeMutability"));
55
				"testChangeMutability"));
57
56
58
	return changeMutabilityCommandTest;
57
		return changeMutabilityCommandTest;
59
    }
58
	}
60
59
61
    /**
60
	/**
62
         * @see junit.framework.TestCase#setUp()
61
	 * @see junit.framework.TestCase#setUp()
63
         */
62
	 */
64
    protected void setUp() throws Exception
63
	protected void setUp() throws Exception
65
    {
64
	{
66
	super.setUp();
65
		super.setUp();
67
    }
66
	}
68
67
69
    /**
68
	/**
70
         * @see junit.framework.TestCase#tearDown()
69
	 * @see junit.framework.TestCase#tearDown()
71
         */
70
	 */
72
    protected void tearDown() throws Exception
71
	protected void tearDown() throws Exception
73
    {
72
	{
74
    }
73
	}
75
74
76
    /**
75
	/**
77
         * testChangeMutability
76
	 * testChangeMutability
78
         * 
77
	 * 
79
         * @throws Exception
78
	 * @throws Exception
80
         */
79
	 */
81
    public void testChangeMutability() throws Exception
80
	public void testChangeMutability() throws Exception
82
    {
81
	{
83
	List properties = capability.getProperties();
82
		List properties = capability.getProperties();
84
	assertNotNull(properties);
83
		assertNotNull(properties);
85
	assertTrue(properties.size() > 0);
84
		assertTrue(properties.size() > 0);
86
	Object object = properties.get(0);
85
		Object object = properties.get(0);
87
	assertTrue(object instanceof Property);
86
		assertTrue(object instanceof Property);
88
	Property property = (Property) object;
87
		Property property = (Property) object;
89
	PropertyType metadata = property.getMetaData();
88
		PropertyType metadata = property.getMetaData();
90
	assertNotNull(metadata.getMutability());
89
		assertNotNull(metadata.getMutability());
91
	assertEquals(MetaDataUtils.CONSTANT, metadata.getMutability()
90
		assertEquals(MetaDataUtils.CONSTANT, metadata.getMutability()
92
		.getLiteral());
91
				.getLiteral());
93
	QName propName = (QName) metadata.getName();
92
		String propName = metadata.getName();
94
93
95
	ChangeMutabilityCommand command = new ChangeMutabilityCommand(
94
		ChangeMutabilityCommand command = new ChangeMutabilityCommand(
96
		capabilityDomain, property, MetaDataUtils.MUTABLE);
95
				capabilityDomain, property, MetaDataUtils.MUTABLE);
97
	command.execute();
96
		command.execute();
98
97
99
	PropertyType changedMetadata = TestUtils.getPropertyType(capability,
98
		PropertyType changedMetadata = TestUtils.getPropertyType(capability,
100
		propName);
99
				propName);
101
	assertNotNull(changedMetadata);
100
		assertNotNull(changedMetadata);
102
	assertEquals(MetaDataUtils.MUTABLE, changedMetadata.getMutability()
101
		assertEquals(MetaDataUtils.MUTABLE, changedMetadata.getMutability()
103
		.getLiteral());
102
				.getLiteral());
104
    }
103
	}
105
104
106
}
105
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/command/property/AddPropertyCommandTest.java (-77 / +77 lines)
Lines 27-110 Link Here
27
 */
27
 */
28
public class AddPropertyCommandTest extends PropertyCommandTestModel
28
public class AddPropertyCommandTest extends PropertyCommandTestModel
29
{
29
{
30
    /**
30
	/**
31
         * Constructor for AddPropertyCommandTest.
31
	 * Constructor for AddPropertyCommandTest.
32
         * 
32
	 * 
33
         * @param name
33
	 * @param name
34
         */
34
	 */
35
    public AddPropertyCommandTest(String name)
35
	public AddPropertyCommandTest(String name)
36
    {
36
	{
37
	super(name);
37
		super(name);
38
    }
38
	}
39
39
40
    /**
40
	/**
41
         * Returns the JUnit test suite that implements the
41
	 * Returns the JUnit test suite that implements the
42
         * <b>AddPropertyCommandTest</b> definition.
42
	 * <b>AddPropertyCommandTest</b> definition.
43
         */
43
	 */
44
    public static Test suite()
44
	public static Test suite()
45
    {
45
	{
46
	HyadesTestSuite addPropertyCommandTest = new HyadesTestSuite(
46
		HyadesTestSuite addPropertyCommandTest = new HyadesTestSuite(
47
		"AddPropertyCommandTest");
47
				"AddPropertyCommandTest");
48
	addPropertyCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
48
		addPropertyCommandTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
49
		"C8E89291F2E4762CE3CFC6500FDF11DB");
49
				"C8E89291F2E4762CE3CFC6500FDF11DB");
50
50
51
	addPropertyCommandTest.addTest(new AddPropertyCommandTest(
51
		addPropertyCommandTest.addTest(new AddPropertyCommandTest(
52
		"testAddProperty"));
52
				"testAddProperty"));
53
53
54
	return addPropertyCommandTest;
54
		return addPropertyCommandTest;
55
    }
55
	}
56
56
57
    /**
57
	/**
58
         * @see junit.framework.TestCase#setUp()
58
	 * @see junit.framework.TestCase#setUp()
59
         */
59
	 */
60
    protected void setUp() throws Exception
60
	protected void setUp() throws Exception
61
    {
61
	{
62
	super.setUp();
62
		super.setUp();
63
    }
63
	}
64
64
65
    /**
65
	/**
66
         * @see junit.framework.TestCase#tearDown()
66
	 * @see junit.framework.TestCase#tearDown()
67
         */
67
	 */
68
    protected void tearDown() throws Exception
68
	protected void tearDown() throws Exception
69
    {
69
	{
70
    }
70
	}
71
71
72
    /**
72
	/**
73
         * testAddProperty
73
	 * testAddProperty
74
         * 
74
	 * 
75
         * @throws Exception
75
	 * @throws Exception
76
         */
76
	 */
77
    public void testAddProperty() throws Exception
77
	public void testAddProperty() throws Exception
78
    {
78
	{
79
	XSDElementDeclaration[] oldWSDLProperties = CapUtils
79
		XSDElementDeclaration[] oldWSDLProperties = CapUtils
80
		.getResolvedProperties(definition, resourcePropertyElement);
80
				.getResolvedProperties(definition, resourcePropertyElement);
81
	XSDElementDeclaration newProperty = TestUtils.createNewProperty();
81
		XSDElementDeclaration newProperty = TestUtils.createNewProperty();
82
	newProperty.setName("dummy");
82
		newProperty.setName("dummy");
83
	XSDElementDeclaration[] oldXSDProperties = TestUtils
83
		XSDElementDeclaration[] oldXSDProperties = TestUtils
84
		.getXSDElementDeclarations(propSchema);
84
				.getXSDElementDeclarations(propSchema);
85
85
86
	AddPropertyCommand command = new AddPropertyCommand(capabilityDomain,
86
		AddPropertyCommand command = new AddPropertyCommand(capabilityDomain,
87
		newProperty);
87
				newProperty);
88
	command.execute();
88
		command.execute();
89
89
90
	XSDElementDeclaration[] newWSDLProperties = CapUtils
90
		XSDElementDeclaration[] newWSDLProperties = CapUtils
91
		.getResolvedProperties(definition, resourcePropertyElement);
91
				.getResolvedProperties(definition, resourcePropertyElement);
92
	XSDElementDeclaration[] newXSDProperties = TestUtils
92
		XSDElementDeclaration[] newXSDProperties = TestUtils
93
		.getXSDElementDeclarations(propSchema);
93
				.getXSDElementDeclarations(propSchema);
94
94
95
	assertNotNull(definition);
95
		assertNotNull(definition);
96
	assertNotNull(resourcePropertyElement);
96
		assertNotNull(resourcePropertyElement);
97
	assertNotNull(propSchema);
97
		assertNotNull(propSchema);
98
	assertTrue(newWSDLProperties.length == oldWSDLProperties.length + 1);
98
		assertTrue(newWSDLProperties.length == oldWSDLProperties.length + 1);
99
	assertTrue(newXSDProperties.length == oldXSDProperties.length + 1);
99
		assertTrue(newXSDProperties.length == oldXSDProperties.length + 1);
100
100
101
	XSDElementDeclaration newProp = XsdUtils
101
		XSDElementDeclaration newProp = XsdUtils
102
		.getXSDElementDeclarationOfName(propSchema, "dummy");
102
				.getXSDElementDeclarationOfName(propSchema, "dummy");
103
	assertTrue(newProperty.equals(newProp));
103
		assertTrue(newProperty.equals(newProp));
104
104
105
	XSDElementDeclaration propRef = getPropertyRef(newProperty);
105
		XSDElementDeclaration propRef = getPropertyRef(newProperty);
106
	assertNotNull(propRef);
106
		assertNotNull(propRef);
107
107
108
    }
108
	}
109
109
110
}
110
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/AllCapabilityTest.java (-30 / +43 lines)
Lines 28-69 Link Here
28
 */
28
 */
29
public class AllCapabilityTest extends HyadesTestCase
29
public class AllCapabilityTest extends HyadesTestCase
30
{
30
{
31
    /**
31
	/**
32
         * Constructor for AllCapabilityTest.
32
	 * Constructor for AllCapabilityTest.
33
         * 
33
	 * 
34
         * @param name
34
	 * @param name
35
         */
35
	 */
36
    public AllCapabilityTest(String name)
36
	public AllCapabilityTest(String name)
37
    {
37
	{
38
	super(name);
38
		super(name);
39
    }
39
	}
40
40
41
    /**
41
	/**
42
	 * Returns the JUnit test suite that implements the <b>AllCapabilityTest</b> definition.
42
	 * Returns the JUnit test suite that implements the <b>AllCapabilityTest</b>
43
	 * definition.
43
	 */
44
	 */
44
	public static Test suite() {
45
	public static Test suite()
45
		HyadesTestSuite allCapabilityTest = new HyadesTestSuite("AllCapabilityTest");
46
	{
46
		allCapabilityTest.setArbiter(DefaultTestArbiter.INSTANCE).setId("D814DB9B58140B8C8745B9E0100B11DB");
47
		HyadesTestSuite allCapabilityTest = new HyadesTestSuite(
47
		allCapabilityTest.addTest(((HyadesTestSuite) AllUtilTest.suite()).setTestInvocationId("C448865E2C0E25D871F8ADE043EB11DB"));
48
				"AllCapabilityTest");
48
		allCapabilityTest.addTest(((HyadesTestSuite) AllOverviewCommandTest.suite()).setTestInvocationId("C70A87B1CB5BD6B9D307683043F811DB"));
49
		allCapabilityTest.setArbiter(DefaultTestArbiter.INSTANCE).setId(
49
		allCapabilityTest.addTest(((HyadesTestSuite) AllPropertyCommandTest.suite()).setTestInvocationId("C70A87B1CB5BD6B9D30D82B043F811DB"));
50
				"D814DB9B58140B8C8745B9E0100B11DB");
50
		allCapabilityTest.addTest(((HyadesTestSuite) AllOperationCommandTest.suite()).setTestInvocationId("C70A87B1CB5BD6B9D2F825FD43F811DB"));
51
		allCapabilityTest.addTest(((HyadesTestSuite) AllUtilTest.suite())
51
		allCapabilityTest.addTest(((HyadesTestSuite) AllTopicCommandTest.suite()).setTestInvocationId("C70A87B1CB5BD6B9D3139D4343F811DB"));
52
				.setTestInvocationId("C448865E2C0E25D871F8ADE043EB11DB"));
53
		allCapabilityTest.addTest(((HyadesTestSuite) AllOverviewCommandTest
54
				.suite())
55
				.setTestInvocationId("C70A87B1CB5BD6B9D307683043F811DB"));
56
		allCapabilityTest.addTest(((HyadesTestSuite) AllPropertyCommandTest
57
				.suite())
58
				.setTestInvocationId("C70A87B1CB5BD6B9D30D82B043F811DB"));
59
		allCapabilityTest.addTest(((HyadesTestSuite) AllOperationCommandTest
60
				.suite())
61
				.setTestInvocationId("C70A87B1CB5BD6B9D2F825FD43F811DB"));
62
		allCapabilityTest.addTest(((HyadesTestSuite) AllTopicCommandTest
63
				.suite())
64
				.setTestInvocationId("C70A87B1CB5BD6B9D3139D4343F811DB"));
52
		return allCapabilityTest;
65
		return allCapabilityTest;
53
	}
66
	}
54
67
55
	/**
68
	/**
56
         * @see junit.framework.TestCase#setUp()
69
	 * @see junit.framework.TestCase#setUp()
57
         */
70
	 */
58
    protected void setUp() throws Exception
71
	protected void setUp() throws Exception
59
    {
72
	{
60
    }
73
	}
61
74
62
    /**
75
	/**
63
         * @see junit.framework.TestCase#tearDown()
76
	 * @see junit.framework.TestCase#tearDown()
64
         */
77
	 */
65
    protected void tearDown() throws Exception
78
	protected void tearDown() throws Exception
66
    {
79
	{
67
    }
80
	}
68
81
69
}
82
}
(-)src/org/eclipse/tptp/wsdm/tooling/validation/capability/test/NullReportCapabilityValidator.java (-14 / +14 lines)
Lines 21-41 Link Here
21
public class NullReportCapabilityValidator implements ICapabilityValidator
21
public class NullReportCapabilityValidator implements ICapabilityValidator
22
{
22
{
23
23
24
    public IValidationReport validateRMD(Definition definition,
24
	public IValidationReport validateRMD(Definition definition,
25
	    DocumentRoot root)
25
			DocumentRoot root)
26
    {
26
	{
27
	return new NullReport();
27
		return new NullReport();
28
    }
28
	}
29
29
30
    public IValidationReport validateWSDL(Definition definition)
30
	public IValidationReport validateWSDL(Definition definition)
31
    {
31
	{
32
	return new NullReport();
32
		return new NullReport();
33
    }
33
	}
34
34
35
    public IValidationReport validateXSD(Definition definition,
35
	public IValidationReport validateXSD(Definition definition,
36
	    XSDSchema properySchema)
36
			XSDSchema properySchema)
37
    {
37
	{
38
	return new NullReport();
38
		return new NullReport();
39
    }
39
	}
40
40
41
}
41
}
(-)src/org/eclipse/tptp/wsdm/tooling/validation/capability/test/AllNullReportCapabilityValidator.java (-14 / +14 lines)
Lines 21-41 Link Here
21
public class AllNullReportCapabilityValidator implements ICapabilityValidator
21
public class AllNullReportCapabilityValidator implements ICapabilityValidator
22
{
22
{
23
23
24
    public IValidationReport validateRMD(Definition definition,
24
	public IValidationReport validateRMD(Definition definition,
25
	    DocumentRoot root)
25
			DocumentRoot root)
26
    {
26
	{
27
	return null;
27
		return null;
28
    }
28
	}
29
29
30
    public IValidationReport validateWSDL(Definition definition)
30
	public IValidationReport validateWSDL(Definition definition)
31
    {
31
	{
32
	return null;
32
		return null;
33
    }
33
	}
34
34
35
    public IValidationReport validateXSD(Definition definition,
35
	public IValidationReport validateXSD(Definition definition,
36
	    XSDSchema properySchema)
36
			XSDSchema properySchema)
37
    {
37
	{
38
	return null;
38
		return null;
39
    }
39
	}
40
40
41
}
41
}
(-)src/org/eclipse/tptp/wsdm/tooling/validation/capability/test/WSDLNullReportCapabilityValidator.java (-14 / +14 lines)
Lines 22-42 Link Here
22
public class WSDLNullReportCapabilityValidator implements ICapabilityValidator
22
public class WSDLNullReportCapabilityValidator implements ICapabilityValidator
23
{
23
{
24
24
25
    public IValidationReport validateRMD(Definition definition,
25
	public IValidationReport validateRMD(Definition definition,
26
	    DocumentRoot root)
26
			DocumentRoot root)
27
    {
27
	{
28
	return new EmptyValidationReport();
28
		return new EmptyValidationReport();
29
    }
29
	}
30
30
31
    public IValidationReport validateWSDL(Definition definition)
31
	public IValidationReport validateWSDL(Definition definition)
32
    {
32
	{
33
	return null;
33
		return null;
34
    }
34
	}
35
35
36
    public IValidationReport validateXSD(Definition definition,
36
	public IValidationReport validateXSD(Definition definition,
37
	    XSDSchema properySchema)
37
			XSDSchema properySchema)
38
    {
38
	{
39
	return new EmptyValidationReport();
39
		return new EmptyValidationReport();
40
    }
40
	}
41
41
42
}
42
}
(-)src/org/eclipse/tptp/wsdm/tooling/validation/capability/test/NullReport.java (-32 / +32 lines)
Lines 18-54 Link Here
18
public class NullReport implements IValidationReport
18
public class NullReport implements IValidationReport
19
{
19
{
20
20
21
    public void addValidationMessage(IValidationMessage message)
21
	public void addValidationMessage(IValidationMessage message)
22
    {
22
	{
23
    }
23
	}
24
24
25
    public void addValidationReport(IValidationReport report)
25
	public void addValidationReport(IValidationReport report)
26
    {
26
	{
27
    }
27
	}
28
28
29
    public IValidationMessage[] getErrorMessages()
29
	public IValidationMessage[] getErrorMessages()
30
    {
30
	{
31
	return null;
31
		return null;
32
    }
32
	}
33
33
34
    public IValidationMessage[] getValidationMessages()
34
	public IValidationMessage[] getValidationMessages()
35
    {
35
	{
36
	return null;
36
		return null;
37
    }
37
	}
38
38
39
    public IValidationMessage[] getWarningMessages()
39
	public IValidationMessage[] getWarningMessages()
40
    {
40
	{
41
	return null;
41
		return null;
42
    }
42
	}
43
43
44
    public boolean hasErrors()
44
	public boolean hasErrors()
45
    {
45
	{
46
	return false;
46
		return false;
47
    }
47
	}
48
48
49
    public boolean hasWarnings()
49
	public boolean hasWarnings()
50
    {
50
	{
51
	return false;
51
		return false;
52
    }
52
	}
53
53
54
}
54
}
(-)src/org/eclipse/tptp/wsdm/tooling/validation/capability/test/RMDNullReportCapabilityValidator.java (-14 / +14 lines)
Lines 22-42 Link Here
22
public class RMDNullReportCapabilityValidator implements ICapabilityValidator
22
public class RMDNullReportCapabilityValidator implements ICapabilityValidator
23
{
23
{
24
24
25
    public IValidationReport validateRMD(Definition definition,
25
	public IValidationReport validateRMD(Definition definition,
26
	    DocumentRoot root)
26
			DocumentRoot root)
27
    {
27
	{
28
	return null;
28
		return null;
29
    }
29
	}
30
30
31
    public IValidationReport validateWSDL(Definition definition)
31
	public IValidationReport validateWSDL(Definition definition)
32
    {
32
	{
33
	return new EmptyValidationReport();
33
		return new EmptyValidationReport();
34
    }
34
	}
35
35
36
    public IValidationReport validateXSD(Definition definition,
36
	public IValidationReport validateXSD(Definition definition,
37
	    XSDSchema properySchema)
37
			XSDSchema properySchema)
38
    {
38
	{
39
	return new EmptyValidationReport();
39
		return new EmptyValidationReport();
40
    }
40
	}
41
41
42
}
42
}
(-)src/org/eclipse/tptp/wsdm/tooling/validation/capability/test/CustomReportCapabilityValidator.java (-34 / +34 lines)
Lines 24-65 Link Here
24
public class CustomReportCapabilityValidator implements ICapabilityValidator
24
public class CustomReportCapabilityValidator implements ICapabilityValidator
25
{
25
{
26
26
27
    public IValidationReport validateRMD(Definition definition,
27
	public IValidationReport validateRMD(Definition definition,
28
	    DocumentRoot root)
28
			DocumentRoot root)
29
    {
29
	{
30
	return getCustomReport();
30
		return getCustomReport();
31
    }
31
	}
32
32
33
    public IValidationReport validateWSDL(Definition definition)
33
	public IValidationReport validateWSDL(Definition definition)
34
    {
34
	{
35
	return getCustomReport();
35
		return getCustomReport();
36
    }
36
	}
37
37
38
    public IValidationReport validateXSD(Definition definition,
38
	public IValidationReport validateXSD(Definition definition,
39
	    XSDSchema properySchema)
39
			XSDSchema properySchema)
40
    {
40
	{
41
	return getCustomReport();
41
		return getCustomReport();
42
    }
42
	}
43
43
44
    private IValidationReport getCustomReport()
44
	private IValidationReport getCustomReport()
45
    {
45
	{
46
	EmptyValidationReport report = new EmptyValidationReport();
46
		EmptyValidationReport report = new EmptyValidationReport();
47
	// Creating Null message, High severity
47
		// Creating Null message, High severity
48
	EmptyValidationMessage message_1 = new EmptyValidationMessage(null,
48
		EmptyValidationMessage message_1 = new EmptyValidationMessage(null,
49
		IValidationMessage.SEV_HIGH);
49
				IValidationMessage.SEV_HIGH);
50
	report.addValidationMessage(message_1);
50
		report.addValidationMessage(message_1);
51
	// Creating Null message, Low severity
51
		// Creating Null message, Low severity
52
	EmptyValidationMessage message_2 = new EmptyValidationMessage(null,
52
		EmptyValidationMessage message_2 = new EmptyValidationMessage(null,
53
		IValidationMessage.SEV_LOW);
53
				IValidationMessage.SEV_LOW);
54
	report.addValidationMessage(message_2);
54
		report.addValidationMessage(message_2);
55
	// Creating Null message, Unknown severity
55
		// Creating Null message, Unknown severity
56
	EmptyValidationMessage message_3 = new EmptyValidationMessage(null, 10);
56
		EmptyValidationMessage message_3 = new EmptyValidationMessage(null, 10);
57
	report.addValidationMessage(message_3);
57
		report.addValidationMessage(message_3);
58
	// Creating some message, Unknown severity
58
		// Creating some message, Unknown severity
59
	EmptyValidationMessage message_4 = new EmptyValidationMessage(
59
		EmptyValidationMessage message_4 = new EmptyValidationMessage(
60
		"Unresolved Location", 10);
60
				"Unresolved Location", 10);
61
	report.addValidationMessage(message_4);
61
		report.addValidationMessage(message_4);
62
	return report;
62
		return report;
63
    }
63
	}
64
64
65
}
65
}
(-)src/org/eclipse/tptp/wsdm/tooling/validation/capability/test/XSDNullReportCapabilityValidator.java (-14 / +14 lines)
Lines 22-42 Link Here
22
public class XSDNullReportCapabilityValidator implements ICapabilityValidator
22
public class XSDNullReportCapabilityValidator implements ICapabilityValidator
23
{
23
{
24
24
25
    public IValidationReport validateRMD(Definition definition,
25
	public IValidationReport validateRMD(Definition definition,
26
	    DocumentRoot root)
26
			DocumentRoot root)
27
    {
27
	{
28
	return new EmptyValidationReport();
28
		return new EmptyValidationReport();
29
    }
29
	}
30
30
31
    public IValidationReport validateWSDL(Definition definition)
31
	public IValidationReport validateWSDL(Definition definition)
32
    {
32
	{
33
	return new EmptyValidationReport();
33
		return new EmptyValidationReport();
34
    }
34
	}
35
35
36
    public IValidationReport validateXSD(Definition definition,
36
	public IValidationReport validateXSD(Definition definition,
37
	    XSDSchema properySchema)
37
			XSDSchema properySchema)
38
    {
38
	{
39
	return null;
39
		return null;
40
    }
40
	}
41
41
42
}
42
}
(-)src/org/eclipse/tptp/wsdm/tooling/validation/capability/test/ValidReportCapabilityValidator.java (-44 / +44 lines)
Lines 24-74 Link Here
24
public class ValidReportCapabilityValidator implements ICapabilityValidator
24
public class ValidReportCapabilityValidator implements ICapabilityValidator
25
{
25
{
26
26
27
    public IValidationReport validateRMD(Definition definition,
27
	public IValidationReport validateRMD(Definition definition,
28
	    DocumentRoot root)
28
			DocumentRoot root)
29
    {
29
	{
30
	EmptyValidationReport report = new EmptyValidationReport();
30
		EmptyValidationReport report = new EmptyValidationReport();
31
31
32
	EmptyValidationMessage message_1 = new EmptyValidationMessage(
32
		EmptyValidationMessage message_1 = new EmptyValidationMessage(
33
		"High severity rmd test message", IValidationMessage.SEV_HIGH);
33
				"High severity rmd test message", IValidationMessage.SEV_HIGH);
34
	EmptyValidationMessage message_2 = new EmptyValidationMessage(
34
		EmptyValidationMessage message_2 = new EmptyValidationMessage(
35
		"Low severity rmd test message", IValidationMessage.SEV_LOW);
35
				"Low severity rmd test message", IValidationMessage.SEV_LOW);
36
36
37
	report.addValidationMessage(message_1);
37
		report.addValidationMessage(message_1);
38
	report.addValidationMessage(message_2);
38
		report.addValidationMessage(message_2);
39
39
40
	return report;
40
		return report;
41
    }
41
	}
42
42
43
    public IValidationReport validateWSDL(Definition definition)
43
	public IValidationReport validateWSDL(Definition definition)
44
    {
44
	{
45
	EmptyValidationReport report = new EmptyValidationReport();
45
		EmptyValidationReport report = new EmptyValidationReport();
46
46
47
	EmptyValidationMessage message_1 = new EmptyValidationMessage(
47
		EmptyValidationMessage message_1 = new EmptyValidationMessage(
48
		"High severity wsdl test message", IValidationMessage.SEV_HIGH);
48
				"High severity wsdl test message", IValidationMessage.SEV_HIGH);
49
	EmptyValidationMessage message_2 = new EmptyValidationMessage(
49
		EmptyValidationMessage message_2 = new EmptyValidationMessage(
50
		"Low severity wsdl test message", IValidationMessage.SEV_LOW);
50
				"Low severity wsdl test message", IValidationMessage.SEV_LOW);
51
51
52
	report.addValidationMessage(message_1);
52
		report.addValidationMessage(message_1);
53
	report.addValidationMessage(message_2);
53
		report.addValidationMessage(message_2);
54
54
55
	return report;
55
		return report;
56
    }
56
	}
57
57
58
    public IValidationReport validateXSD(Definition definition,
58
	public IValidationReport validateXSD(Definition definition,
59
	    XSDSchema propertySchema)
59
			XSDSchema propertySchema)
60
    {
60
	{
61
	EmptyValidationReport report = new EmptyValidationReport();
61
		EmptyValidationReport report = new EmptyValidationReport();
62
62
63
	EmptyValidationMessage message_1 = new EmptyValidationMessage(
63
		EmptyValidationMessage message_1 = new EmptyValidationMessage(
64
		"High severity xsd test message", IValidationMessage.SEV_HIGH);
64
				"High severity xsd test message", IValidationMessage.SEV_HIGH);
65
	EmptyValidationMessage message_2 = new EmptyValidationMessage(
65
		EmptyValidationMessage message_2 = new EmptyValidationMessage(
66
		"Low severity xsd test message", IValidationMessage.SEV_LOW);
66
				"Low severity xsd test message", IValidationMessage.SEV_LOW);
67
67
68
	report.addValidationMessage(message_1);
68
		report.addValidationMessage(message_1);
69
	report.addValidationMessage(message_2);
69
		report.addValidationMessage(message_2);
70
70
71
	return report;
71
		return report;
72
    }
72
	}
73
73
74
}
74
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/model/test/XSDTestModel.java (-41 / +41 lines)
Lines 25-72 Link Here
25
public class XSDTestModel extends HyadesTestCase
25
public class XSDTestModel extends HyadesTestCase
26
{
26
{
27
27
28
    protected String XSD_FILE_PATH = Activator.PLUGIN_ID + "/"
28
	protected String XSD_FILE_PATH = Activator.PLUGIN_ID + "/"
29
	    + "testfiles/xsd/webapplication.xsd";
29
			+ "testfiles/xsd/webapplication.xsd";
30
30
31
    protected XSDSchema web_application_schema;
31
	protected XSDSchema web_application_schema;
32
32
33
    protected String[] WEB_APP_ELEMENT_NAMES = new String[] { "WebApp",
33
	protected String[] WEB_APP_ELEMENT_NAMES = new String[] { "WebApp",
34
	    "ContextParam", "Servlet", "ServletMapping", "SessionConfig",
34
			"ContextParam", "Servlet", "ServletMapping", "SessionConfig",
35
	    "MimeMapping", "WelcomeFileList", "ErrorPage", "TagLibRef",
35
			"MimeMapping", "WelcomeFileList", "ErrorPage", "TagLibRef",
36
	    "SecurityConstraint", "WebResourceCollection", "AuthConstraint",
36
			"SecurityConstraint", "WebResourceCollection", "AuthConstraint",
37
	    "UserDataConstraint", "LoginConfig", "FormLoginConfig",
37
			"UserDataConstraint", "LoginConfig", "FormLoginConfig",
38
	    "InitParam", "WebType", "ServletType", "JSPType", "URLPatternType",
38
			"InitParam", "WebType", "ServletType", "JSPType", "URLPatternType",
39
	    "RoleNameType", "WelcomeFile", "ExceptionTypeErrorPage",
39
			"RoleNameType", "WelcomeFile", "ExceptionTypeErrorPage",
40
	    "ErrorCodeErrorPage", "FilterMapping", "Filter",
40
			"ErrorCodeErrorPage", "FilterMapping", "Filter",
41
	    "LocalEncodingMappingList", "LocalEncodingMapping",
41
			"LocalEncodingMappingList", "LocalEncodingMapping",
42
	    "HTTPMethodType" };
42
			"HTTPMethodType" };
43
43
44
    protected String[] WEB_APP_ELEMENT_TYPES = new String[] { "WebApp",
44
	protected String[] WEB_APP_ELEMENT_TYPES = new String[] { "WebApp",
45
	    "ContextParam", "Servlet", "ServletMapping", "SessionConfig",
45
			"ContextParam", "Servlet", "ServletMapping", "SessionConfig",
46
	    "MimeMapping", "WelcomeFileList", "ErrorPage", "TagLibRef",
46
			"MimeMapping", "WelcomeFileList", "ErrorPage", "TagLibRef",
47
	    "SecurityConstraint", "WebResourceCollection", "AuthConstraint",
47
			"SecurityConstraint", "WebResourceCollection", "AuthConstraint",
48
	    "UserDataConstraint", "LoginConfig", "FormLoginConfig",
48
			"UserDataConstraint", "LoginConfig", "FormLoginConfig",
49
	    "InitParam", "WebType", "ServletType", "JSPType", "URLPatternType",
49
			"InitParam", "WebType", "ServletType", "JSPType", "URLPatternType",
50
	    "RoleNameType", "WelcomeFile", "ExceptionTypeErrorPage",
50
			"RoleNameType", "WelcomeFile", "ExceptionTypeErrorPage",
51
	    "ErrorCodeErrorPage", "FilterMapping", "Filter",
51
			"ErrorCodeErrorPage", "FilterMapping", "Filter",
52
	    "LocalEncodingMappingList", "LocalEncodingMapping",
52
			"LocalEncodingMappingList", "LocalEncodingMapping",
53
	    "HTTPMethodType" };
53
			"HTTPMethodType" };
54
54
55
    protected String[] IMPORTED_NS = new String[] { "java.xmi", "jsp.xmi",
55
	protected String[] IMPORTED_NS = new String[] { "java.xmi", "jsp.xmi",
56
	    "common.xmi", "http://www.omg.org/XMI" };
56
			"common.xmi", "http://www.omg.org/XMI" };
57
57
58
    public XSDTestModel(String name)
58
	public XSDTestModel(String name)
59
    {
59
	{
60
	super(name);
60
		super(name);
61
    }
61
	}
62
62
63
    protected void setUp() throws Exception
63
	protected void setUp() throws Exception
64
    {
64
	{
65
	IFile web_app_xsd_file = EclipseUtils.getIFile(XSD_FILE_PATH);
65
		IFile web_app_xsd_file = EclipseUtils.getIFile(XSD_FILE_PATH);
66
	assertNotNull(web_app_xsd_file);
66
		assertNotNull(web_app_xsd_file);
67
67
68
	web_application_schema = XsdUtils.getSchema(web_app_xsd_file);
68
		web_application_schema = XsdUtils.getSchema(web_app_xsd_file);
69
	assertNotNull(web_application_schema);
69
		assertNotNull(web_application_schema);
70
    }
70
	}
71
71
72
}
72
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/model/test/WSDLTestModel.java (-37 / +37 lines)
Lines 25-70 Link Here
25
public class WSDLTestModel extends HyadesTestCase
25
public class WSDLTestModel extends HyadesTestCase
26
{
26
{
27
27
28
    protected String WSDL_FILE_PATH = Activator.PLUGIN_ID + "/"
28
	protected String WSDL_FILE_PATH = Activator.PLUGIN_ID + "/"
29
	    + "testfiles/wsdl/WarehouseFront.wsdl";
29
			+ "testfiles/wsdl/WarehouseFront.wsdl";
30
30
31
    protected Definition ware_house_front_defintion;
31
	protected Definition ware_house_front_defintion;
32
32
33
    protected String TARGET_NS = "http://ejb.warehouse.samples.websphere.ibm.com";
33
	protected String TARGET_NS = "http://ejb.warehouse.samples.websphere.ibm.com";
34
34
35
    protected String TARGET_NS_PREFIX = "impl";
35
	protected String TARGET_NS_PREFIX = "impl";
36
36
37
    protected String PORT_TYPE_NAME = "WarehouseFront_SEI";
37
	protected String PORT_TYPE_NAME = "WarehouseFront_SEI";
38
38
39
    protected String[][] NAMESPACE_DEFINED = new String[][] {
39
	protected String[][] NAMESPACE_DEFINED = new String[][] {
40
	    { "impl", "http://ejb.warehouse.samples.websphere.ibm.com" },
40
			{ "impl", "http://ejb.warehouse.samples.websphere.ibm.com" },
41
	    { "tns2", "http://xml.apache.org/xml-soap" },
41
			{ "tns2", "http://xml.apache.org/xml-soap" },
42
	    { "tns3", "http://beans.greenhouse.samples.websphere.ibm.com" },
42
			{ "tns3", "http://beans.greenhouse.samples.websphere.ibm.com" },
43
	    { "wsdl", "http://schemas.xmlsoap.org/wsdl/" },
43
			{ "wsdl", "http://schemas.xmlsoap.org/wsdl/" },
44
	    { "wsdlsoap", "http://schemas.xmlsoap.org/wsdl/soap/" },
44
			{ "wsdlsoap", "http://schemas.xmlsoap.org/wsdl/soap/" },
45
	    { "xsd", "http://www.w3.org/2001/XMLSchema" } };
45
			{ "xsd", "http://www.w3.org/2001/XMLSchema" } };
46
46
47
    protected String[] XSD_SCHEMAS_DEFINED = new String[] {
47
	protected String[] XSD_SCHEMAS_DEFINED = new String[] {
48
	    "http://xml.apache.org/xml-soap",
48
			"http://xml.apache.org/xml-soap",
49
	    "http://ejb.warehouse.samples.websphere.ibm.com",
49
			"http://ejb.warehouse.samples.websphere.ibm.com",
50
	    "http://beans.greenhouse.samples.websphere.ibm.com" };
50
			"http://beans.greenhouse.samples.websphere.ibm.com" };
51
51
52
    protected String[] OPERATION_NAMES = new String[] { "startOrder",
52
	protected String[] OPERATION_NAMES = new String[] { "startOrder",
53
	    "receiveItems" };
53
			"receiveItems" };
54
54
55
    public WSDLTestModel(String name)
55
	public WSDLTestModel(String name)
56
    {
56
	{
57
	super(name);
57
		super(name);
58
    }
58
	}
59
59
60
    protected void setUp() throws Exception
60
	protected void setUp() throws Exception
61
    {
61
	{
62
	IFile ware_house_front_xsd_file = EclipseUtils.getIFile(WSDL_FILE_PATH);
62
		IFile ware_house_front_xsd_file = EclipseUtils.getIFile(WSDL_FILE_PATH);
63
	assertNotNull(ware_house_front_xsd_file);
63
		assertNotNull(ware_house_front_xsd_file);
64
64
65
	ware_house_front_defintion = WsdlUtils
65
		ware_house_front_defintion = WsdlUtils
66
		.getWSDLDefinition(ware_house_front_xsd_file);
66
				.getWSDLDefinition(ware_house_front_xsd_file);
67
	assertNotNull(ware_house_front_defintion);
67
		assertNotNull(ware_house_front_defintion);
68
    }
68
	}
69
69
70
}
70
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/model/test/CapabilityTestModel.java (-85 / +83 lines)
Lines 20-28 Link Here
20
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
20
import org.eclipse.tptp.wsdm.tooling.editor.capability.internal.CapabilityDomain;
21
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
21
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
22
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
22
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
23
import org.eclipse.tptp.wsdm.tooling.model.capabilities.impl.MetadataDescriptor;
23
import org.eclipse.tptp.wsdm.tooling.util.internal.Definition2Capability;
24
import org.eclipse.tptp.wsdm.tooling.util.internal.Definition2Capability;
24
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
25
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
25
import org.eclipse.tptp.wsdm.tooling.util.internal.PropertyMetaDataDescriptor;
26
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
26
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
27
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
27
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils;
28
import org.eclipse.wst.wsdl.Definition;
28
import org.eclipse.wst.wsdl.Definition;
Lines 38-135 Link Here
38
public class CapabilityTestModel extends HyadesTestCase
38
public class CapabilityTestModel extends HyadesTestCase
39
{
39
{
40
40
41
    protected Definition definition;
41
	protected Definition definition;
42
42
43
    protected String CAPABILITY_FILE_PATH = null;
43
	protected String CAPABILITY_FILE_PATH = null;
44
44
45
    protected XSDElementDeclaration resourcePropertyElement;
45
	protected XSDElementDeclaration resourcePropertyElement;
46
46
47
    protected Capability capability;
47
	protected Capability capability;
48
48
49
    protected XSDSchema propSchema;
49
	protected XSDSchema propSchema;
50
50
51
    protected PropertyMetaDataDescriptor metaDataDescriptor;
51
	protected MetadataDescriptor metaDataDescriptor;
52
52
53
    protected CapabilityDomain capabilityDomain;
53
	protected CapabilityDomain capabilityDomain;
54
54
55
    public CapabilityTestModel(String name, String capabilityIFilePath)
55
	public CapabilityTestModel(String name, String capabilityIFilePath)
56
    {
56
	{
57
	super(name);
57
		super(name);
58
	if (capabilityIFilePath == null)
58
		if (capabilityIFilePath == null)
59
	    throw new AssertionFailedError(
59
			throw new AssertionFailedError(
60
		    "Capability file path must be specified");
60
					"Capability file path must be specified");
61
	CAPABILITY_FILE_PATH = capabilityIFilePath;
61
		CAPABILITY_FILE_PATH = capabilityIFilePath;
62
    }
62
	}
63
63
64
    protected void setUp() throws Exception
64
	protected void setUp() throws Exception
65
    {
65
	{
66
	IFile capabilityFile = EclipseUtils.getIFile(CAPABILITY_FILE_PATH);
66
		IFile capabilityFile = EclipseUtils.getIFile(CAPABILITY_FILE_PATH);
67
	assertNotNull(capabilityFile);
67
		assertNotNull(capabilityFile);
68
68
69
	definition = WsdlUtils.getWSDLDefinition(capabilityFile);
69
		definition = WsdlUtils.getWSDLDefinition(capabilityFile);
70
	assertNotNull(definition);
70
		assertNotNull(definition);
71
71
72
	Definition2Capability def2cap = new Definition2Capability(definition);
72
		Definition2Capability def2cap = new Definition2Capability(definition);
73
	capability = def2cap.getCapability();
73
		capability = def2cap.getCapability();
74
	assertNotNull(capability);
74
		assertNotNull(capability);
75
	capabilityDomain = new CapabilityDomain();
75
		capabilityDomain = new CapabilityDomain();
76
	capabilityDomain.setDefinition(definition);
76
		capabilityDomain.setCapability(capability);
77
	capabilityDomain.setCapability(capability);
77
		List propList = capability.getProperties();
78
	List propList = capability.getProperties();
78
		assertNotNull(propList);
79
	assertNotNull(propList);
79
		assertTrue(propList.size() > 0);
80
	assertTrue(propList.size() > 0);
80
81
81
		resourcePropertyElement = def2cap.getResourcePropertyElement();
82
	resourcePropertyElement = def2cap.getResourcePropertyElement();
82
		assertNotNull(resourcePropertyElement);
83
	assertNotNull(resourcePropertyElement);
83
		capabilityDomain.setResourcePropertyElement(resourcePropertyElement);
84
	capabilityDomain.setResourcePropertyElement(resourcePropertyElement);
84
85
85
		Object propertySchema = getPropertySchema(capability);
86
	Object propertySchema = getPropertySchema(capability);
86
		assertNotNull(propertySchema);
87
	assertNotNull(propertySchema);
87
		assertTrue(propertySchema instanceof XSDSchema);
88
	assertTrue(propertySchema instanceof XSDSchema);
88
		propSchema = (XSDSchema) propertySchema;
89
	propSchema = (XSDSchema) propertySchema;
89
		capabilityDomain.setPropertySchema(propSchema);
90
	capabilityDomain.setPropertySchema(propSchema);
90
91
91
		metaDataDescriptor = def2cap.getCapability().getMetadata();
92
	metaDataDescriptor = def2cap.getPropertyMetaDataDescriptor();
92
		assertNotNull(metaDataDescriptor);
93
	assertNotNull(metaDataDescriptor);
93
	}
94
	capabilityDomain.setMetaDataDescriptor(metaDataDescriptor);
94
95
    }
95
	protected XSDElementDeclaration getPropertyRef(
96
96
			XSDElementDeclaration property)
97
    protected XSDElementDeclaration getPropertyRef(
98
	    XSDElementDeclaration property)
99
    {
100
	XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) resourcePropertyElement
101
		.getAnonymousTypeDefinition();
102
	XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef);
103
	XSDElementDeclaration[] elementRefs = XsdUtils
104
		.getElementDeclarations(modelGroup);
105
	for (int i = 0; i < elementRefs.length; i++)
106
	{
97
	{
107
	    if (XsdUtils.isReferencedElement(elementRefs[i]))
98
		XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) resourcePropertyElement
108
	    {
99
				.getAnonymousTypeDefinition();
109
		XSDElementDeclaration element = elementRefs[i]
100
		XSDModelGroup modelGroup = XsdUtils.getXSDModelGroup(typeDef);
110
			.getResolvedElementDeclaration();
101
		XSDElementDeclaration[] elementRefs = XsdUtils
111
		if (element.getName().equals(property.getName())
102
				.getElementDeclarations(modelGroup);
112
			&& element.getTargetNamespace().equals(
103
		for (int i = 0; i < elementRefs.length; i++)
113
				property.getTargetNamespace()))
104
		{
114
		    return elementRefs[i];
105
			if (XsdUtils.isReferencedElement(elementRefs[i]))
115
	    }
106
			{
107
				XSDElementDeclaration element = elementRefs[i]
108
						.getResolvedElementDeclaration();
109
				if (element.getName().equals(property.getName())
110
						&& element.getTargetNamespace().equals(
111
								property.getTargetNamespace()))
112
					return elementRefs[i];
113
			}
114
		}
115
		return null;
116
	}
116
	}
117
	return null;
118
    }
119
117
120
    private XSDSchema getPropertySchema(Capability capability)
118
	private XSDSchema getPropertySchema(Capability capability)
121
    {
122
	String capNS = capability.getNamespace();
123
	List propList = capability.getProperties();
124
	for (int i = 0; i < propList.size(); i++)
125
	{
119
	{
126
	    Property property = (Property) propList.get(i);
120
		String capNS = capability.getNamespace();
127
	    XSDElementDeclaration element = property.getElement();
121
		List propList = capability.getProperties();
128
	    if (element != null)
122
		for (int i = 0; i < propList.size(); i++)
129
		if (element.getTargetNamespace().equals(capNS))
123
		{
130
		    return element.getSchema();
124
			Property property = (Property) propList.get(i);
125
			XSDElementDeclaration element = property.getElement();
126
			if (element != null)
127
				if (element.getTargetNamespace().equals(capNS))
128
					return element.getSchema();
129
		}
130
		return null;
131
	}
131
	}
132
	return null;
133
    }
134
132
135
}
133
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/capability/model/test/RMDTestModel.java (-70 / +70 lines)
Lines 26-123 Link Here
26
public class RMDTestModel extends HyadesTestCase
26
public class RMDTestModel extends HyadesTestCase
27
{
27
{
28
28
29
    protected String RMD_FILE_PATH = Activator.PLUGIN_ID + "/"
29
	protected String RMD_FILE_PATH = Activator.PLUGIN_ID + "/"
30
	    + "testfiles/capability/util/AppServer.rmd";
30
			+ "testfiles/capability/util/AppServer.rmd";
31
31
32
    protected DocumentRoot root;
32
	protected DocumentRoot root;
33
33
34
    protected MetadataDescriptorType metaDescriptor;
34
	protected MetadataDescriptorType metaDescriptor;
35
35
36
    protected String descriptorName = "AppServerDescriptor";
36
	protected String descriptorName = "AppServerDescriptor";
37
37
38
    protected int NO_OF_PROPERTIES = 3;
38
	protected int NO_OF_PROPERTIES = 3;
39
39
40
    protected class PropertyMetadata
40
	protected class PropertyMetadata
41
    {
41
	{
42
	public String propertyName;
42
		public String propertyName;
43
43
44
	public String modifiability;
44
		public String modifiability;
45
45
46
	public String mutability;
46
		public String mutability;
47
47
48
	public Object[] validValues;
48
		public Object[] validValues;
49
49
50
	public Object[] staticValues;
50
		public Object[] staticValues;
51
51
52
	public boolean hasMetric;
52
		public boolean hasMetric;
53
53
54
	public Metric metric;
54
		public Metric metric;
55
55
56
	PropertyMetadata(String propertyName, String modifiability,
56
		PropertyMetadata(String propertyName, String modifiability,
57
		String mutability, Object[] validValues, Object[] staticValues,
57
				String mutability, Object[] validValues, Object[] staticValues,
58
		boolean hasMetric, Metric metric)
58
				boolean hasMetric, Metric metric)
59
	{
59
		{
60
	    this.propertyName = propertyName;
60
			this.propertyName = propertyName;
61
	    this.modifiability = modifiability;
61
			this.modifiability = modifiability;
62
	    this.mutability = mutability;
62
			this.mutability = mutability;
63
	    this.validValues = validValues;
63
			this.validValues = validValues;
64
	    this.staticValues = staticValues;
64
			this.staticValues = staticValues;
65
	    this.hasMetric = hasMetric;
65
			this.hasMetric = hasMetric;
66
	    this.metric = metric;
66
			this.metric = metric;
67
		}
67
	}
68
	}
68
    }
69
69
70
    protected class Metric
70
	protected class Metric
71
    {
71
	{
72
	public String changeType;
72
		public String changeType;
73
73
74
	public String timeScope;
74
		public String timeScope;
75
75
76
	public String gatheringTime;
76
		public String gatheringTime;
77
77
78
	public String calculationInterval;
78
		public String calculationInterval;
79
80
		Metric(String changeType, String timeScope, String gatheringTime,
81
				String calculationInterval)
82
		{
83
			this.changeType = changeType;
84
			this.timeScope = timeScope;
85
			this.gatheringTime = gatheringTime;
86
			this.calculationInterval = calculationInterval;
87
		}
88
	}
79
89
80
	Metric(String changeType, String timeScope, String gatheringTime,
90
	protected PropertyMetadata home_metadata;
81
		String calculationInterval)
91
92
	protected PropertyMetadata connectionPool_metadata;
93
94
	public RMDTestModel(String name)
82
	{
95
	{
83
	    this.changeType = changeType;
96
		super(name);
84
	    this.timeScope = timeScope;
85
	    this.gatheringTime = gatheringTime;
86
	    this.calculationInterval = calculationInterval;
87
	}
97
	}
88
    }
89
98
90
    protected PropertyMetadata home_metadata;
99
	protected void setUp() throws Exception
100
	{
101
		IFile rmdFile = EclipseUtils.getIFile(RMD_FILE_PATH);
102
		assertNotNull(rmdFile);
91
103
92
    protected PropertyMetadata connectionPool_metadata;
104
		root = MetaDataUtils.getDocumentRoot(rmdFile);
105
		assertNotNull(root);
93
106
94
    public RMDTestModel(String name)
107
		metaDescriptor = MetaDataUtils.getMetadataDescriptorType(root,
95
    {
108
				descriptorName);
96
	super(name);
109
		assertNotNull(metaDescriptor);
97
    }
110
98
111
		Object[] validValues = new String[] { "jdbc_home", "j2ee_home",
99
    protected void setUp() throws Exception
112
				"jsp_home", "was_home" };
100
    {
113
		Object[] staticValues = new String[] { "j2ee_home", "was_home" };
101
	IFile rmdFile = EclipseUtils.getIFile(RMD_FILE_PATH);
114
		home_metadata = new PropertyMetadata("home", MetaDataUtils.READ_ONLY,
102
	assertNotNull(rmdFile);
115
				MetaDataUtils.CONSTANT, validValues, staticValues, false, null);
103
116
104
	root = MetaDataUtils.getDocumentRoot(rmdFile);
117
		Metric metric = new Metric("Gauge", "PointInTime", "Periodic", "PT1M");
105
	assertNotNull(root);
118
		connectionPool_metadata = new PropertyMetadata("connectionPool",
106
119
				MetaDataUtils.WRITABLE, MetaDataUtils.MUTABLE, new Object[0],
107
	metaDescriptor = MetaDataUtils.getMetadataDescriptorType(root,
120
				new Object[0], true, metric);
108
		descriptorName);
121
	}
109
	assertNotNull(metaDescriptor);
110
111
	Object[] validValues = new String[] { "jdbc_home", "j2ee_home",
112
		"jsp_home", "was_home" };
113
	Object[] staticValues = new String[] { "j2ee_home", "was_home" };
114
	home_metadata = new PropertyMetadata("home", MetaDataUtils.READ_ONLY,
115
		MetaDataUtils.CONSTANT, validValues, staticValues, false, null);
116
117
	Metric metric = new Metric("Gauge", "PointInTime", "Periodic", "PT1M");
118
	connectionPool_metadata = new PropertyMetadata("connectionPool",
119
		MetaDataUtils.WRITABLE, MetaDataUtils.MUTABLE, new Object[0],
120
		new Object[0], true, metric);
121
    }
122
122
123
}
123
}

Return to bug 161932