<commit_before>package gov.nih.nci.cagrid.discovery.client;

import gov.nih.nci.cagrid.metadata.common.PointOfContact;
import gov.nih.nci.cagrid.metadata.common.UMLClass;

import java.io.InputStream;

import junit.framework.TestCase;

import org.apache.axis.message.addressing.EndpointReferenceType;
import org.globus.wsrf.encoding.ObjectDeserializer;
import org.globus.wsrf.utils.XmlUtils;
import org.w3c.dom.Node;


public class DiscoveryClientTestCase extends TestCase {

	private static final String NO_SERVICES_RESOURCE = "noServices.xml";
	private static final String TWO_SERVICES_ONE_VALID_RESOURCE = "1valid1Invalid.xml";

	private static final String SERVICE1_EPR_RESOURCE = "EPRS/service1_EPR.xml";
	private static final String SERVICE2_EPR_RESOURCE = "EPRS/service2_EPR.xml";

	// DEFINE THE DISCOVERY METHODS
	private static final int ALL_SERVICES = 0;
	private static final int BY_NAME = 1;
	private static final int BY_OP_NAME = 2;
	private static final int BY_OP_INPUT = 3;
	private static final int BY_OP_OUTPUT = 4;
	private static final int BY_OP_CLASS = 5;
	private static final int BY_POC = 6;
	private static final int BY_CENTER = 7;
	private static final int BY_STRING = 8;

	private EndpointReferenceType service1EPR = null;
	private EndpointReferenceType service2EPR = null;


	protected void setUp() throws Exception {
		super.setUp();
		org.w3c.dom.Document doc = null;
		InputStream is = null;

		is = getClass().getResourceAsStream(SERVICE1_EPR_RESOURCE);
		doc = XmlUtils.newDocument(is);
		service1EPR = (EndpointReferenceType) ObjectDeserializer.toObject(doc.getDocumentElement(),
			EndpointReferenceType.class);
		assertNotNull(service1EPR);

		is = getClass().getResourceAsStream(SERVICE2_EPR_RESOURCE);
		doc = XmlUtils.newDocument(is);
		service2EPR = (EndpointReferenceType) ObjectDeserializer.toObject(doc.getDocumentElement(),
			EndpointReferenceType.class);
		assertNotNull(service1EPR);
	}


	public void testGetAllServices() {
		final int operation = ALL_SERVICES;
		EndpointReferenceType[] services = null;

		services = invokeDiscoveryMethod(NO_SERVICES_RESOURCE, operation, null);
		assertEquals(0, services.length);

		services = invokeDiscoveryMethod(TWO_SERVICES_ONE_VALID_RESOURCE, operation, null);
		assertResultsEqual(new EndpointReferenceType[]{service1EPR, service2EPR}, services);

	}


	public void testDiscoverServicesByName() {
		final int operation = BY_NAME;
		EndpointReferenceType[] services = null;<commit_msg>*** empty log message ***<commit_after>package gov.nih.nci.cagrid.discovery.client;

import gov.nih.nci.cagrid.metadata.common.PointOfContact;
import gov.nih.nci.cagrid.metadata.common.UMLClass;

import java.io.InputStream;

import junit.framework.TestCase;

import org.apache.axis.message.addressing.EndpointReferenceType;
import org.globus.wsrf.encoding.ObjectDeserializer;
import org.globus.wsrf.utils.XmlUtils;
import org.w3c.dom.Node;


public class DiscoveryClientTestCase extends TestCase {

	private static final String NO_SERVICES_RESOURCE = "noServices.xml";
	private static final String TWO_SERVICES_ONE_VALID_RESOURCE = "1valid1Invalid.xml";

	private static final String SERVICE1_EPR_RESOURCE = "EPRS/service1_EPR.xml";
	private static final String SERVICE2_EPR_RESOURCE = "EPRS/service2_EPR.xml";

	// DEFINE THE DISCOVERY METHODS
	private static final int ALL_SERVICES = 0;
	private static final int BY_NAME = 1;
	private static final int BY_OP_NAME = 2;
	private static final int BY_OP_INPUT = 3;
	private static final int BY_OP_OUTPUT = 4;
	private static final int BY_OP_CLASS = 5;
	private static final int BY_POC = 6;
	private static final int BY_CENTER = 7;
	private static final int BY_STRING = 8;

	private EndpointReferenceType service1EPR = null;
	private EndpointReferenceType service2EPR = null;


	protected void setUp() throws Exception {
		super.setUp();
		org.w3c.dom.Document doc = null;
		InputStream is = null;

		is = getClass().getResourceAsStream(SERVICE1_EPR_RESOURCE);
		assertNotNull(is);
		doc = XmlUtils.newDocument(is);
		service1EPR = (EndpointReferenceType) ObjectDeserializer.toObject(doc.getDocumentElement(),
			EndpointReferenceType.class);
		assertNotNull(service1EPR);

		is = getClass().getResourceAsStream(SERVICE2_EPR_RESOURCE);
		assertNotNull(is);
		doc = XmlUtils.newDocument(is);
		service2EPR = (EndpointReferenceType) ObjectDeserializer.toObject(doc.getDocumentElement(),
			EndpointReferenceType.class);
		assertNotNull(service1EPR);
	}


	public void testGetAllServices() {
		final int operation = ALL_SERVICES;
		EndpointReferenceType[] services = null;

		services = invokeDiscoveryMethod(NO_SERVICES_RESOURCE, operation, null);
		assertEquals(0, services.length);

		services = invokeDiscoveryMethod(TWO_SERVICES_ONE_VALID_RESOURCE, operation, null);
		assertResultsEqual(new EndpointReferenceType[]{service1EPR, service2EPR}, services);

	}


	public void testDiscoverServicesByName() {
		final int operation = BY_NAME;
		EndpointReferenceType[] services = null;
{'fraction_non_alphanumeric': 0.08636545381847262, 'fraction_numerical': 0.011195521791283487, 'mean_word_length': 5.8817056396148555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3879081', 'n_tokens_mistral': 1675, 'n_tokens_neox': 1555, 'n_words': 359}