| 1 |
/* |
| 2 |
* Copyright 1999-2010 University of Chicago |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 |
* express or implied. |
| 12 |
* |
| 13 |
* See the License for the specific language governing permissions and limitations under the License. |
| 14 |
*/ |
| 15 |
package org.globus.common; |
| 16 |
|
| 17 |
import junit.framework.TestCase; |
| 18 |
import org.globus.common.ResourceManagerContact; |
| 19 |
|
| 20 |
public class ResourceManagerContactTest extends TestCase { |
| 21 |
|
| 22 |
public void testBasic() throws Exception { |
| 23 |
ResourceManagerContact c = null; |
| 24 |
|
| 25 |
c = new ResourceManagerContact("pitcairn.mcs.anl.gov"); |
| 26 |
verify(c, "pitcairn.mcs.anl.gov", 2119); |
| 27 |
|
| 28 |
c = new ResourceManagerContact("pitcairn.mcs.anl.gov:123"); |
| 29 |
verify(c, "pitcairn.mcs.anl.gov", 123); |
| 30 |
|
| 31 |
c = new ResourceManagerContact("pitcairn.mcs.anl.gov:123/job"); |
| 32 |
verify(c, "pitcairn.mcs.anl.gov", 123, "/job"); |
| 33 |
|
| 34 |
c = new ResourceManagerContact("pitcairn.mcs.anl.gov/job"); |
| 35 |
verify(c, "pitcairn.mcs.anl.gov", 2119, "/job"); |
| 36 |
|
| 37 |
c = new ResourceManagerContact("pitcairn.mcs.anl.gov:/job"); |
| 38 |
verify(c, "pitcairn.mcs.anl.gov", 2119, "/job"); |
| 39 |
|
| 40 |
c = new ResourceManagerContact("pitcairn.mcs.anl.gov::cn=jarek"); |
| 41 |
verify(c, "pitcairn.mcs.anl.gov", 2119, "/jobmanager", "cn=jarek"); |
| 42 |
|
| 43 |
c = new ResourceManagerContact("pitcairn.mcs.anl.gov:123:cn=jarek"); |
| 44 |
verify(c, "pitcairn.mcs.anl.gov", 123, "/jobmanager", "cn=jarek"); |
| 45 |
|
| 46 |
c = new ResourceManagerContact("pitcairn.mcs.anl.gov:/job:cn=jarek"); |
| 47 |
verify(c, "pitcairn.mcs.anl.gov", 2119, "/job", "cn=jarek"); |
| 48 |
|
| 49 |
c = new ResourceManagerContact("pitcairn.mcs.anl.gov/job:cn=jarek"); |
| 50 |
verify(c, "pitcairn.mcs.anl.gov", 2119, "/job", "cn=jarek"); |
| 51 |
|
| 52 |
c = new ResourceManagerContact("pitcairn.mcs.anl.gov:123/job:cn=jarek"); |
| 53 |
verify(c, "pitcairn.mcs.anl.gov", 123, "/job", "cn=jarek"); |
| 54 |
} |
| 55 |
|
| 56 |
public void testBasicIPv6() throws Exception { |
| 57 |
ResourceManagerContact c = null; |
| 58 |
c = new ResourceManagerContact("[3ffe:2a00:100:7031::1]"); |
| 59 |
verify(c, "[3ffe:2a00:100:7031::1]", 2119); |
| 60 |
|
| 61 |
c = new ResourceManagerContact("[3ffe:2a00:100:7031::1]:123"); |
| 62 |
verify(c, "[3ffe:2a00:100:7031::1]", 123); |
| 63 |
|
| 64 |
c = new ResourceManagerContact("[3ffe:2a00:100:7031::1]/job"); |
| 65 |
verify(c, "[3ffe:2a00:100:7031::1]", 2119, "/job"); |
| 66 |
} |
| 67 |
|
| 68 |
private void verify(ResourceManagerContact contact, String hostname, int port) { |
| 69 |
verify(contact, hostname, port, "/jobmanager", null); |
| 70 |
} |
| 71 |
|
| 72 |
private void verify(ResourceManagerContact contact, String hostname, int port, String serviceName) { |
| 73 |
verify(contact, hostname, port, serviceName, null); |
| 74 |
} |
| 75 |
|
| 76 |
private void verify(ResourceManagerContact contact, String hostname, int port, String serviceName, String dn) { |
| 77 |
assertEquals("hostname", hostname, contact.getHostName()); |
| 78 |
assertEquals("port", port, contact.getPortNumber()); |
| 79 |
assertEquals("service", serviceName, contact.getServiceName()); |
| 80 |
assertEquals("dn", dn, contact.getGlobusDN()); |
| 81 |
} |
| 82 |
|
| 83 |
} |