blob: ce9bf9509e69178da5839ca33d6958a2a8117f40 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*******************************************************************************
* Copyright (c) 2002-2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
package org.eclipse.wst.wsi.internal.profile.validator.impl.wsdl;
import java.net.URI;
import javax.wsdl.Import;
import org.eclipse.wst.wsi.internal.WSIException;
import org.eclipse.wst.wsi.internal.analyzer.AssertionFailException;
import org.eclipse.wst.wsi.internal.analyzer.AssertionNotApplicableException;
import org.eclipse.wst.wsi.internal.profile.TestAssertion;
import org.eclipse.wst.wsi.internal.profile.validator.EntryContext;
import org.eclipse.wst.wsi.internal.profile.validator.impl.AssertionProcess;
import org.eclipse.wst.wsi.internal.report.AssertionResult;
/**
* BP2803
* <context>For a candidate wsdl:import element</context>
* <assertionDescription>The "namespace" attribute is specified for the wsdl:import element, and the attribute's value is not a relative URI.</assertionDescription>
*/
public class BP2803 extends AssertionProcess
{
private final WSDLValidatorImpl validator;
/**
* @param WSDLValidatorImpl
*/
public BP2803(WSDLValidatorImpl impl)
{
super(impl);
this.validator = impl;
}
/* Validates the test assertion.
* @see org.wsi.test.profile.validator.impl.BaseValidatorImpl.AssertionProcess#validate(org.wsi.test.profile.TestAssertion, org.wsi.test.profile.validator.EntryContext)
*/
public AssertionResult validate(
TestAssertion testAssertion,
EntryContext entryContext)
throws WSIException
{
// Getting wsdl:import
Import im = (Import) entryContext.getEntry().getEntryDetail();
try
{
// If there is no the "namespace" attribute in the import,
// the assertion is not applicable
if (im.getNamespaceURI() == null)
{
throw new AssertionNotApplicableException();
}
// If a namespace URI is relative or invalid, the assertion failed
URI uri = new URI(im.getNamespaceURI());
if (!uri.isAbsolute())
{
throw new AssertionFailException(
im.getNamespaceURI() + " is relative URI.");
}
}
catch (AssertionNotApplicableException anae)
{
result = AssertionResult.RESULT_NOT_APPLICABLE;
}
catch (Exception e)
{
result = AssertionResult.RESULT_FAILED;
failureDetail = validator.createFailureDetail(
e.getMessage(), entryContext);
}
return validator.createAssertionResult(
testAssertion, result, failureDetail);
}
}
|