| 1 |
/* |
| 2 |
* Copyright 2000,2004 The Apache Software Foundation. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package test.wsdl.multiref; |
| 18 |
|
| 19 |
/** |
| 20 |
* MultiRefTestSOAPBindingImpl.java |
| 21 |
* |
| 22 |
* @author Rich Scheuerle ([email protected]) |
| 23 |
*/ |
| 24 |
public class MultiRefTestSOAPBindingImpl implements test.wsdl.multiref.MultiRefTest { |
| 25 |
|
| 26 |
/** |
| 27 |
* Tests for the following arrangement of nodes: |
| 28 |
* 0 |
| 29 |
* / \ |
| 30 |
* 1 2 |
| 31 |
*/ |
| 32 |
public int testSimpleTree(test.wsdl.multiref.holders.NodeHolder root) throws java.rmi.RemoteException { |
| 33 |
Node t = root.value; // Root of tree |
| 34 |
Node l = t.getLeft(); // Left side |
| 35 |
Node r = t.getRight(); // Right side |
| 36 |
|
| 37 |
if (t != null && l != null && r != null && |
| 38 |
r != l && |
| 39 |
l.getLeft() == null && |
| 40 |
l.getRight()== null && |
| 41 |
r.getLeft() == null && |
| 42 |
r.getRight()== null) |
| 43 |
return 0; // Great |
| 44 |
|
| 45 |
return 1; // Bad |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Tests for the following arrangement of nodes: |
| 50 |
* 0 |
| 51 |
* / \ |
| 52 |
* 1 2 |
| 53 |
* \ / |
| 54 |
* 3 |
| 55 |
*/ |
| 56 |
public int testDiamond(test.wsdl.multiref.holders.NodeHolder root) throws java.rmi.RemoteException { |
| 57 |
Node t = root.value; // Root of tree |
| 58 |
Node l = t.getLeft(); // Left side |
| 59 |
Node r = t.getRight(); // Right side |
| 60 |
|
| 61 |
if (t != null && l != null && r != null && |
| 62 |
r != l && |
| 63 |
l.getLeft() == null && |
| 64 |
r.getRight()== null && |
| 65 |
l.getRight()!= null && |
| 66 |
l.getRight()== r.getLeft()) |
| 67 |
return 0; // Great |
| 68 |
|
| 69 |
return 1; // Bad |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Tests for the following arrangement of nodes: |
| 74 |
* 0 |
| 75 |
* / \ |
| 76 |
* 1 2 and the children of 1 & 2 are backward references to 0 |
| 77 |
*/ |
| 78 |
public int testLoop(test.wsdl.multiref.holders.NodeHolder root) throws java.rmi.RemoteException { |
| 79 |
Node t = root.value; // Root of tree |
| 80 |
Node l = t.getLeft(); // Left side |
| 81 |
Node r = t.getRight(); // Right side |
| 82 |
|
| 83 |
if (t != null && l != null && r != null && |
| 84 |
r != l && |
| 85 |
l.getLeft() == t && |
| 86 |
l.getRight()== t && |
| 87 |
r.getLeft() == t && |
| 88 |
r.getRight()== t) |
| 89 |
return 0; // Great |
| 90 |
|
| 91 |
return 1; // Bad |
| 92 |
} |
| 93 |
/** |
| 94 |
* Tests for the following arrangement of nodes: |
| 95 |
* 0 |
| 96 |
* and the children of 0 are backward references to 0 |
| 97 |
*/ |
| 98 |
public int testSelfRef(test.wsdl.multiref.holders.NodeHolder root) throws java.rmi.RemoteException { |
| 99 |
Node t = root.value; // Root of tree |
| 100 |
Node l = t.getLeft(); // Left side |
| 101 |
Node r = t.getRight(); // Right side |
| 102 |
|
| 103 |
if (t != null && l != null && r != null && |
| 104 |
t == l && t == r) |
| 105 |
return 0; // Great |
| 106 |
|
| 107 |
return 1; // Bad |
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* Tests that both arguments are the same node & the nodes don't have children |
| 112 |
*/ |
| 113 |
public int testSameArgs(test.wsdl.multiref.holders.NodeHolder root1,test.wsdl.multiref.holders.NodeHolder root2) |
| 114 |
throws java.rmi.RemoteException { |
| 115 |
Node t1 = root1.value; // Root1 of tree |
| 116 |
Node t2 = root2.value; // Root2 of tree |
| 117 |
|
| 118 |
if (t1 != null && t2 != null && |
| 119 |
t1 == t2 && |
| 120 |
t1.getRight() == null && |
| 121 |
t1.getLeft() == null) |
| 122 |
return 0; // Great |
| 123 |
|
| 124 |
return 1; // Bad |
| 125 |
} |
| 126 |
|
| 127 |
/** |
| 128 |
* Tests for the following arrangement of nodes: |
| 129 |
* 0 1 |
| 130 |
* \ / |
| 131 |
* 2 where 0 and 1 are the argument nodes. |
| 132 |
*/ |
| 133 |
public int testArgsRefSameNode(test.wsdl.multiref.holders.NodeHolder root1,test.wsdl.multiref.holders.NodeHolder root2) |
| 134 |
throws java.rmi.RemoteException { |
| 135 |
Node t1 = root1.value; // Root1 of tree |
| 136 |
Node t2 = root2.value; // Root2 of tree |
| 137 |
|
| 138 |
if (t1 != null && t2 != null && |
| 139 |
t1 != t2 && |
| 140 |
t1.getLeft() == null && |
| 141 |
t2.getRight() == null && |
| 142 |
t1.getRight() != null && |
| 143 |
t1.getRight() == t2.getLeft() && |
| 144 |
t1.getRight().getRight() == null && |
| 145 |
t1.getRight().getLeft() == null) |
| 146 |
return 0; // Great |
| 147 |
|
| 148 |
return 1; // Bad |
| 149 |
} |
| 150 |
/** |
| 151 |
* Tests for two node arguments that reference each other. |
| 152 |
*/ |
| 153 |
public int testArgsRefEachOther(test.wsdl.multiref.holders.NodeHolder root1,test.wsdl.multiref.holders.NodeHolder root2) |
| 154 |
throws java.rmi.RemoteException { |
| 155 |
Node t1 = root1.value; // Root1 of tree |
| 156 |
Node t2 = root2.value; // Root2 of tree |
| 157 |
|
| 158 |
if (t1 != null && t2 != null && |
| 159 |
t1 != t2 && |
| 160 |
t1.getLeft() == t2 && |
| 161 |
t1.getRight() == t2 && |
| 162 |
t2.getLeft() == t1 && |
| 163 |
t2.getRight() == t1) |
| 164 |
return 0; // Great |
| 165 |
|
| 166 |
return 1; // Bad |
| 167 |
} |
| 168 |
|
| 169 |
} |