text:
FactoryGirl.define do
  factory :procedure_occurrence do
  end
end

redpajama_set_name: RedPajamaGithub


text:
ES5Harness.registerTest( {
id: "15.2.3.3-0-2",

path: "TestCases/chapter15/15.2/15.2.3/15.2.3.3/15.2.3.3-0-2.js",

description: "Object.getOwnPropertyDescriptor must exist as a function taking 2 parameters",

test: function testcase() {
  if (Object.getOwnPropertyDescriptor.length === 2) {
    return true;
  }
 },

precondition: function prereq() {
  return fnExists(Object.getOwnPropertyDescriptor);
 }
});


text:
package com.manning.sdmia.dataaccess.service.test;

import java.util.ArrayList;
import java.util.List;

import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests;
import org.springframework.osgi.test.platform.Platforms;
import org.springframework.osgi.test.provisioning.ArtifactLocator;
import org.springframework.osgi.test.provisioning.internal.LocalFileSystemMavenRepository;

import com.manning.sdmia.dataaccess.domain.model.Address;
import com.manning.sdmia.dataaccess.domain.model.Contact;
import com.manning.sdmia.dataaccess.service.ContactsService;

public class JdbcContactsServiceTest extends AbstractConfigurableBundleCreatorTests {
	private ContactsService contactsService;

	protected String getPlatformName() {
		return Platforms.EQUINOX;
	}

	public void testSimpleJpaEclipseLinkService() {
		waitOnContextCreation("com.manning.sdmia.ch07-dataaccess-simple");

		List<Contact> contacts = contactsService.getContacts();
		assertEquals(3, contacts.size());

		//row 1
		Contact contact1 = contacts.get(0);
		assertEquals(1, contact1.getId());
		assertEquals("Piper", contact1.getLastName());
		assertEquals("Andy", contact1.getFirstName());
		assertEquals(0, contact1.getAddresses().size());

		//row 2
		Contact contact2 = contacts.get(1);
		assertEquals(2, contact2.getId());
		assertEquals("Cogoluègnes", contact2.getLastName());
		assertEquals("Arnaud", contact2.getFirstName());
		assertEquals(0, contact2.getAddresses().size());

		//row 3
		Contact contact3 = contacts.get(2);
		assertEquals(3, contact3.getId());
		assertEquals("Templier", contact3.getLastName());
		assertEquals("Thierry", contact3.getFirstName());
		assertEquals(1, contact3.getAddresses().size());
		Address address31 = contact3.getAddresses().get(0);
		assertEquals("Saint Nazaire", address31.getCity());
	}

	protected String[] getTestBundlesNames() {
		return new String[] {
				"org.slf4j, com.springsource.slf4j.log4j, 1.5.6",
				"com.manning.sdmia, org.springframework.osgi.log4j.config, 1.0-SNAPSHOT",
				"org.slf4j, com.springsource.slf4j.org.apache.commons.logging, 1.5.6",
				"org.slf4j, com.springsource.slf4j.api, 1.5.6",
				"org.springframework.osgi, log4j.osgi, 1.2.15-SNAPSHOT",
				"org.springframework, org.springframework.transaction, 2.5.6.A",
				"org.springframework, org.springframework.jdbc, 2.5.6.A",
				"javax.persistence, com.springsource.javax.persistence, 1.0.0",
				"com.manning.sdmia, com.springsource.com.mchange.v2.c3p0.config, 1.0-SNAPSHOT",
				"com.mchange.c3p0, com.springsource.com.mchange.v2.c3p0, 0.9.1.2",
				"org.hsqldb, com.springsource.org.hsqldb, 1.8.0.9",
				"org.springframework, org.springframework.jdbc, 2.5.6.A",
				"com.manning.sdmia, ch07-jdbc-datasource, 1.0-SNAPSHOT",
				"com.manning.sdmia, ch07-dataaccess-simple-1.0, SNAPSHOT",
				"com.manning.sdmia, ch07-jdbc-simple, 1.0-SNAPSHOT"
		};
	}

	protected Resource[] getTestFrameworkBundles() {
		String[] testFrameworkBundles = new String[] {
				"org.aspectj, com.springsource.org.aspectj.weaver, 1.6.2.RELEASE",
				"org.aspectj, com.springsource.org.aspectj.runtime, 1.6.2.RELEASE",
				"org.junit, com.springsource.junit, 3.8.2",
				"org.objectweb.asm, com.springsource.org.objectweb.asm, 2.2.3",
				"org.aopalliance, com.springsource.org.aopalliance, 1.0.0",
				"org.springframework, org.springframework.aop, 2.5.6.A",
				"org.springframework, org.springframework.beans, 2.5.6.A",
				"org.springframework, org.springframework.context, 2.5.6.A",
				"org.springframework, org.springframework.context.support, 2.5.6.A",
				"org.springframework, org.springframework.core, 2.5.6.A",
				"org.springframework, org.springframework.test, 2.5.6.A",
				"org.springframework.osgi, spring-osgi-annotation, 1.2.0",
				"org.springframework.osgi, spring-osgi-core, 1.2.0",
				"org.springframework.osgi, spring-osgi-extender, 1.2.0",
				"org.springframework.osgi, spring-osgi-io, 1.2.0",
				"org.springframework.osgi, spring-osgi-test, 1.2.0"
		};
		return locateBundles(testFrameworkBundles);
	}

	protected String[] getConfigLocations() {
		return new String[] { "classpath:/com/manning/sdmia/dataaccess/service/test/osgi-context.xml" };
	}

	protected String getManifestLocation() {
		return "classpath:/com/manning/sdmia/dataaccess/service/test/TestJdbcManifest.MF";
	}

	public ContactsService getContactsService() {
		return contactsService;
	}

	public void setContactsService(ContactsService contactsService) {
		this.contactsService = contactsService;
	}

}


text:
"""
Copyright 2015 SmartBear Software

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

    Ref: https://github.com/swagger-api/swagger-codegen
"""

from pprint import pformat
from six import iteritems

class Manager100ManagerLinks(object):
    """
    NOTE: This class is auto generated by the swagger code generator program.
    Do not edit the class manually.
    """
    def __init__(self):
        """
        Manager100ManagerLinks - a model defined in Swagger

        :param dict swaggerTypes: The key is attribute name
                                  and the value is attribute type.
        :param dict attributeMap: The key is attribute name
                                  and the value is json key in definition.
        """
        self.swagger_types = {
            'manager_for_serversodata_count': 'Odata400Count',
            'manager_for_servers': 'list[ComputerSystemComputerSystem]',
            'manager_for_chassisodata_navigation_link': 'Odata400IdRef',
            'oem': 'ResourceOem',
            'manager_for_chassis': 'list[ChassisChassis]',
            'manager_for_chassisodata_count': 'Odata400Count',
            'manager_for_serversodata_navigation_link': 'Odata400IdRef'
        }

        self.attribute_map = {
            'manager_for_serversodata_count': 'ManagerForServers@odata.count',
            'manager_for_servers': 'ManagerForServers',
            'manager_for_chassisodata_navigation_link': 'ManagerForChassis@odata.navigationLink',
            'oem': 'Oem',
            'manager_for_chassis': 'ManagerForChassis',
            'manager_for_chassisodata_count': 'ManagerForChassis@odata.count',
            'manager_for_serversodata_navigation_link': 'ManagerForServers@odata.navigationLink'
        }

        self._manager_for_serversodata_count = None
        self._manager_for_servers = None
        self._manager_for_chassisodata_navigation_link = None
        self._oem = None
        self._manager_for_chassis = None
        self._manager_for_chassisodata_count = None
        self._manager_for_serversodata_navigation_link = None

    @property
    def manager_for_serversodata_count(self):
        """
        Gets the manager_for_serversodata_count of this Manager100ManagerLinks.

        :return: The manager_for_serversodata_count of this Manager100ManagerLinks.
        :rtype: Odata400Count
        """
        return self._manager_for_serversodata_count

    @manager_for_serversodata_count.setter
    def manager_for_serversodata_count(self, manager_for_serversodata_count):
        """
        Sets the manager_for_serversodata_count of this Manager100ManagerLinks.

        :param manager_for_serversodata_count: The manager_for_serversodata_count of this Manager100ManagerLinks.
        :type: Odata400Count
        """
        self._manager_for_serversodata_count = manager_for_serversodata_count

    @property
    def manager_for_servers(self):
        """
        Gets the manager_for_servers of this Manager100ManagerLinks.
        This property is an array of references to the systems that this manager has control over.

        :return: The manager_for_servers of this Manager100ManagerLinks.
        :rtype: list[ComputerSystemComputerSystem]
        """
        return self._manager_for_servers

    @manager_for_servers.setter
    def manager_for_servers(self, manager_for_servers):
        """
        Sets the manager_for_servers of this Manager100ManagerLinks.
        This property is an array of references to the systems that this manager has control over.

        :param manager_for_servers: The manager_for_servers of this Manager100ManagerLinks.
        :type: list[ComputerSystemComputerSystem]
        """
        self._manager_for_servers = manager_for_servers

    @property
    def manager_for_chassisodata_navigation_link(self):
        """
        Gets the manager_for_chassisodata_navigation_link of this Manager100ManagerLinks.

        :return: The manager_for_chassisodata_navigation_link of this Manager100ManagerLinks.
        :rtype: Odata400IdRef
        """
        return self._manager_for_chassisodata_navigation_link

    @manager_for_chassisodata_navigation_link.setter
    def manager_for_chassisodata_navigation_link(self, manager_for_chassisodata_navigation_link):
        """
        Sets the manager_for_chassisodata_navigation_link of this Manager100ManagerLinks.

        :param manager_for_chassisodata_navigation_link: The manager_for_chassisodata_navigation_link of this Manager100ManagerLinks.
        :type: Odata400IdRef
        """
        self._manager_for_chassisodata_navigation_link = manager_for_chassisodata_navigation_link

    @property
    def oem(self):
        """
        Gets the oem of this Manager100ManagerLinks.
        Oem extension object.

        :return: The oem of this Manager100ManagerLinks.
        :rtype: ResourceOem
        """
        return self._oem

    @oem.setter
    def oem(self, oem):
        """
        Sets the oem of this Manager100ManagerLinks.
        Oem extension object.

        :param oem: The oem of this Manager100ManagerLinks.
        :type: ResourceOem
        """
        self._oem = oem

    @property
    def manager_for_chassis(self):
        """
        Gets the manager_for_chassis of this Manager100ManagerLinks.
        This property is an array of references to the chasis that this manager has control over.

        :return: The manager_for_chassis of this Manager100ManagerLinks.
        :rtype: list[ChassisChassis]
        """
        return self._manager_for_chassis

    @manager_for_chassis.setter
    def manager_for_chassis(self, manager_for_chassis):
        """
        Sets the manager_for_chassis of this Manager100ManagerLinks.
        This property is an array of references to the chasis that this manager has control over.

        :param manager_for_chassis: The manager_for_chassis of this Manager100ManagerLinks.
        :type: list[ChassisChassis]
        """
        self._manager_for_chassis = manager_for_chassis

    @property
    def manager_for_chassisodata_count(self):
        """
        Gets the manager_for_chassisodata_count of this Manager100ManagerLinks.

        :return: The manager_for_chassisodata_count of this Manager100ManagerLinks.
        :rtype: Odata400Count
        """
        return self._manager_for_chassisodata_count

    @manager_for_chassisodata_count.setter
    def manager_for_chassisodata_count(self, manager_for_chassisodata_count):
        """
        Sets the manager_for_chassisodata_count of this Manager100ManagerLinks.

        :param manager_for_chassisodata_count: The manager_for_chassisodata_count of this Manager100ManagerLinks.
        :type: Odata400Count
        """
        self._manager_for_chassisodata_count = manager_for_chassisodata_count

    @property
    def manager_for_serversodata_navigation_link(self):
        """
        Gets the manager_for_serversodata_navigation_link of this Manager100ManagerLinks.

        :return: The manager_for_serversodata_navigation_link of this Manager100ManagerLinks.
        :rtype: Odata400IdRef
        """
        return self._manager_for_serversodata_navigation_link

    @manager_for_serversodata_navigation_link.setter
    def manager_for_serversodata_navigation_link(self, manager_for_serversodata_navigation_link):
        """
        Sets the manager_for_serversodata_navigation_link of this Manager100ManagerLinks.

        :param manager_for_serversodata_navigation_link: The manager_for_serversodata_navigation_link of this Manager100ManagerLinks.
        :type: Odata400IdRef
        """
        self._manager_for_serversodata_navigation_link = manager_for_serversodata_navigation_link

    def to_dict(self):
        """
        Returns the model properties as a dict
        """
        result = {}

        for attr, _ in iteritems(self.swagger_types):
            value = getattr(self, attr)
            if isinstance(value, list):
                result[attr] = list(map(
                    lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
                    value
                ))
            elif hasattr(value, "to_dict"):
                result[attr] = value.to_dict()
            else:
                result[attr] = value

        return result

    def to_str(self):
        """
        Returns the string representation of the model
        """
        return pformat(self.to_dict())

    def __repr__(self):
        """
        For `print` and `pprint`
        """
        return self.to_str()

    def __eq__(self, other):
        """
        Returns true if both objects are equal
        """
        return self.__dict__ == other.__dict__

    def __ne__(self, other):
        """
        Returns true if both objects are not equal
        """
        return not self == other


text:
package org.jetbrains.idea.maven.dom;

import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.impl.config.IntentionActionWrapper;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.formatter.xml.XmlCodeStyleSettings;
import com.intellij.util.PathUtil;
import com.intellij.util.Producer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.maven.MavenCustomRepositoryHelper;
import org.jetbrains.idea.maven.dom.intentions.ChooseFileIntentionAction;
import org.jetbrains.idea.maven.dom.model.MavenDomDependency;
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MavenDependencyCompletionAndResolutionTest extends MavenDomWithIndicesTestCase {
  @Override
  protected void setUpInWriteAction() throws Exception {
    super.setUpInWriteAction();
    importProject("<groupId>test</groupId>" +
                  "<artifactId>project</artifactId>" +
                  "<version>1</version>");
  }

  public void testGroupIdCompletion() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId><caret></groupId>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariantsInclude(myProjectPom, "junit", "jmock", "test");
  }

  public void testArtifactIdCompletion() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId><caret></artifactId>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom, "junit");
  }

  public void testDoNotCompleteArtifactIdOnUnknownGroup() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>unknown</groupId>" +
                     "    <artifactId><caret></artifactId>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom);
  }

  public void testVersionCompletion() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId>junit</artifactId>" +
                     "    <version><caret></version>" +
                     "  </dependency>" +
                     "</dependencies>");

    List<String> variants = getCompletionVariants(myProjectPom);
    assertEquals(Arrays.asList("4.0", "3.8.2", "3.8.1"), variants);
  }

  public void testDoesNotCompleteVersionOnUnknownGroupOrArtifact() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>unknown</groupId>" +
                     "    <artifactId>junit</artifactId>" +
                     "    <version><caret></version>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom);

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId>unknown</artifactId>" +
                     "    <version><caret></version>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom);
  }

  public void testDoNotCompleteVersionIfNoGroupIdAndArtifactId() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <version><caret></version>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom); // should not throw
  }

  public void testAddingLocalProjectsIntoCompletion() throws Exception {
    createProjectPom("<groupId>project-group</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<modules>" +
                     " <module>m1</module>" +
                     " <module>m2</module>" +
                     "</modules>");

    createModulePom("m1",
                    "<groupId>project-group</groupId>" +
                    "<artifactId>m1</artifactId>" +
                    "<version>1</version>");

    VirtualFile m = createModulePom("m2",
                                    "<groupId>project-group</groupId>" +
                                    "<artifactId>m2</artifactId>" +
                                    "<version>2</version>");

    importProject();

    createModulePom("m2", "<groupId>project-group</groupId>" +
                    "<artifactId>m2</artifactId>" +
                    "<version>2</version>" +

                    "<dependencies>" +
                    "  <dependency>" +
                    "    <groupId>project-group</groupId>" +
                    "    <artifactId><caret></artifactId>" +
                    "  </dependency>" +
                    "</dependencies>");

    assertCompletionVariants(m, "project", "m1", "m2");
  }

  public void testResolvingPropertiesForLocalProjectsInCompletion() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<properties>" +
                     "  <module1Name>module1</module1Name>" +
                     "</properties>" +

                     "<modules>" +
                     " <module>m1</module>" +
                     " <module>m2</module>" +
                     "</modules>");

    createModulePom("m1",
                    "<groupId>${pom.parent.groupId}</groupId>" +
                    "<artifactId>${module1Name}</artifactId>" +

                    "<parent>" +
                    "  <groupId>test</groupId>" +
                    "  <artifactId>project</artifactId>" +
                    "  <version>1</version>" +
                    "</parent>");

    VirtualFile m = createModulePom("m2",
                                    "<groupId>test</groupId>" +
                                    "<artifactId>module2</artifactId>" +
                                    "<version>1</version>");

    importProject();
    assertModules("project", "module1", "module2");

    createModulePom("m2", "<groupId>test</groupId>" +
                    "<artifactId>module2</artifactId>" +
                    "<version>1</version>" +
                    "<dependencies>" +
                    "  <dependency>" +
                    "    <groupId>test</groupId>" +
                    "    <artifactId>module1</artifactId>" +
                    "    <version><caret></version>" +
                    "  </dependency>" +
                    "</dependencies>");

    assertCompletionVariants(m, "1");

    createModulePom("m2", "<groupId>test</groupId>" +
                    "<artifactId>module2</artifactId>" +
                    "<version>1</version>" +

                    "<dependencies>" +
                    "  <dependency>" +
                    "    <groupId>test</groupId>" +
                    "    <artifactId>module1</artifactId>" +
                    "    <version>1</version>" +
                    "  </dependency>" +
                    "</dependencies>");

    checkHighlighting(m);
  }

  public void testChangingExistingProjects() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<modules>" +
                     " <module>m1</module>" +
                     " <module>m2</module>" +
                     "</modules>");

    VirtualFile m1 = createModulePom("m1",
                                     "<groupId>test</groupId>" +
                                     "<artifactId>m1</artifactId>" +
                                     "<version>1</version>");

    createModulePom("m2",
                    "<groupId>test</groupId>" +
                    "<artifactId>m2</artifactId>" +
                    "<version>1</version>");
    importProject();

    createModulePom("m1", "<groupId>test</groupId>" +
                    "<artifactId>m1</artifactId>" +
                    "<version>1</version>" +

                    "<dependencies>" +
                    "  <dependency>" +
                    "    <groupId>test</groupId>" +
                    "    <artifactId><caret></artifactId>" +
                    "  </dependency>" +
                    "</dependencies>");

    assertCompletionVariants(m1, "project", "m1", "m2");

    createModulePom("m1", "<groupId>test</groupId>" +
                    "<artifactId>m1</artifactId>" +
                    "<version>1</version>");

    createModulePom("m2", "<groupId>test</groupId>" +
                    "<artifactId>m2_new</artifactId>" +
                    "<version>1</version>");

    importProject();

    createModulePom("m1", "<groupId>test</groupId>" +
                          "<artifactId>m1</artifactId>" +
                          "<version>1</version>" +

                          "<dependencies>" +
                          "  <dependency>" +
                          "    <groupId>test</groupId>" +
                          "    <artifactId><caret></artifactId>" +
                          "  </dependency>" +
                          "</dependencies>");

    assertCompletionVariants(m1, "project", "m1", "m2_new");
  }

  public void testChangingExistingProjectsWithArtifactIdsRemoval() throws Exception {
    VirtualFile m = createModulePom("m1",
                                    "<groupId>project-group</groupId>" +
                                    "<artifactId>m1</artifactId>" +
                                    "<version>1</version>");

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>project-group</groupId>" +
                     "    <artifactId><caret></artifactId>" +
                     "  </dependency>" +
                     "</dependencies>");

    importProjects(myProjectPom, m);

    assertCompletionVariants(myProjectPom, "m1");

    createModulePom("m1", "");
    importProjects(myProjectPom, m);

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>project-group</groupId>" +
                     "    <artifactId><caret></artifactId>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom);
  }

  public void testRemovingExistingProjects() throws Exception {
    final VirtualFile m = createModulePom("m1",
                                    "<groupId>project-group</groupId>" +
                                    "<artifactId>m1</artifactId>" +
                                    "<version>1</version>");

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>project-group</groupId>" +
                     "    <artifactId><caret></artifactId>" +
                     "  </dependency>" +
                     "</dependencies>");

    importProjects(myProjectPom, m);

    assertCompletionVariants(myProjectPom, "m1");

    myProjectsManager.listenForExternalChanges();
    new WriteAction() {
      protected void run(@NotNull Result result) throws Throwable {
        m.delete(null);
      }
    }.execute();

    waitForReadingCompletion();

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>project-group</groupId>" +
                     "    <artifactId><caret></artifactId>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom);
  }

  public void testResolutionOutsideTheProject() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId><caret>junit</artifactId>" +
                     "    <version>4.0</version>" +
                     "  </dependency>" +
                     "</dependencies>");

    String filePath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom");
    VirtualFile f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
    assertResolved(myProjectPom, findPsiFile(f));
  }

  public void testResolveManagedDependency() throws Exception {
    importProject("<groupId>test</groupId>" +
                  "<artifactId>project</artifactId>" +
                  "<version>1</version>" +

                  "<dependencyManagement>" +
                  "  <dependencies>" +
                  "    <dependency>" +
                  "      <groupId>junit</groupId>" +
                  "      <artifactId>junit</artifactId>" +
                  "      <version>4.0</version>" +
                  "    </dependency>" +
                  "  </dependencies>" +
                  "</dependencyManagement>" +

                  "<dependencies>" +
                  "  <dependency>" +
                  "    <groupId>junit</groupId>" +
                  "    <artifactId>junit<caret></artifactId>" +
                  "  </dependency>" +
                  "</dependencies>");

    String filePath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom");
    VirtualFile f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
    assertResolved(myProjectPom, findPsiFile(f));
  }

  public void testResolveSystemManagedDependency() throws Exception {
    String someJarPath = PathUtil.getJarPathForClass(ArrayList.class).replace('\\', '/');

    importProject("<groupId>test</groupId>" +
                  "<artifactId>project</artifactId>" +
                  "<version>1</version>" +

                  "<dependencyManagement>" +
                  "  <dependencies>" +
                  "    <dependency>" +
                  "      <groupId>direct-system-dependency</groupId>" +
                  "      <artifactId>direct-system-dependency</artifactId>" +
                  "      <version>1.0</version>" +
                  "      <scope>system</scope>" +
                  "      <systemPath>" + someJarPath + "</systemPath>" +
                  "    </dependency>" +
                  "  </dependencies>" +
                  "</dependencyManagement>" +

                  "<dependencies>" +
                  "  <dependency>" +
                  "    <groupId>direct-system-dependency</groupId>" +
                  "    <artifactId>direct-system-dependency</artifactId>" +
                  "  </dependency>" +
                  "</dependencies>");

    createProjectPom("<groupId>test</groupId>" +
                      "<artifactId>project</artifactId>" +
                      "<version>1</version>" +

                      "<dependencyManagement>" +
                      "  <dependencies>" +
                      "    <dependency>" +
                      "      <groupId>direct-system-dependency</groupId>" +
                      "      <artifactId>direct-system-dependency</artifactId>" +
                      "      <version>1.0</version>" +
                      "      <scope>system</scope>" +
                      "      <systemPath>" + someJarPath + "</systemPath>" +
                      "    </dependency>" +
                      "  </dependencies>" +
                      "</dependencyManagement>" +

                      "<dependencies>" +
                      "  <dependency>" +
                      "    <groupId>direct-system-dependency</groupId>" +
                      "    <artifactId>direct-system-dependency</artifactId>" +
                      "  </dependency>" +
                      "</dependencies>");

    checkHighlighting(myProjectPom, true, false, true);
  }

  public void testResolveLATESTDependency() throws Exception {
    MavenCustomRepositoryHelper helper = new MavenCustomRepositoryHelper(myDir, "local1");
    String repoPath = helper.getTestDataPath("local1");
    setRepositoryPath(repoPath);

    importProject("<groupId>test</groupId>" +
                  "<artifactId>project</artifactId>" +
                  "<version>1</version>" +

                  "<dependencies>" +
                  "  <dependency>" +
                  "    <groupId>junit</groupId>" +
                  "    <artifactId>junit</artifactId>" +
                  "    <version>[1,4.0]</version>" +
                  "  </dependency>" +
                  "</dependencies>");

    createProjectPom("<groupId>test</groupId>" +
                      "<artifactId>project</artifactId>" +
                      "<version>1</version>" +

                      "<dependencies>" +
                      "  <dependency>" +
                      "    <groupId>junit</groupId>" +
                      "    <artifactId>junit<caret></artifactId>" +
                      "    <version>[1,4.0]</version>" +
                      "  </dependency>" +
                      "</dependencies>");

    String filePath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom");
    VirtualFile f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);

    assertResolved(myProjectPom, findPsiFile(f));
  }

  public void testResolutionIsTypeBased() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId><caret>junit</artifactId>" +
                     "    <version>4.0</version>" +
                     "    <type>pom</type>" +
                     "  </dependency>" +
                     "</dependencies>");

    String filePath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom");
    VirtualFile f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
    assertResolved(myProjectPom, findPsiFile(f));
  }

  public void testResolutionInsideTheProject() throws Exception {
    VirtualFile m1 = createModulePom("m1",
                                     "<groupId>test</groupId>" +
                                     "<artifactId>m1</artifactId>" +
                                     "<version>1</version>");

    VirtualFile m2 = createModulePom("m2",
                                     "<groupId>test</groupId>" +
                                     "<artifactId>m2</artifactId>" +
                                     "<version>1</version>");

    importProjects(myProjectPom, m1, m2);

    createModulePom("m1",
                    "<groupId>test</groupId>" +
                    "<artifactId>m1</artifactId>" +
                    "<version>1</version>" +

                    "<dependencies>" +
                    "  <dependency>" +
                    "    <groupId>test</groupId>" +
                    "    <artifactId><caret>m2</artifactId>" +
                    "    <version>1</version>" +
                    "  </dependency>" +
                    "</dependencies>");

    assertResolved(m1, findPsiFile(m2));
  }

  public void testResolvingSystemScopeDependencies() throws Throwable {
    String libPath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar");

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>xxx</groupId>" +
                     "    <artifactId>xxx</artifactId>" +
                     "    <version><caret>xxx</version>" +
                     "    <scope>system</scope>" +
                     "    <systemPath>" + libPath + "</systemPath>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertResolved(myProjectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath)));
    checkHighlighting();
  }

  public void testHighlightInvalidSystemScopeDependencies() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId><error>xxx</error></groupId>" +
                     "    <artifactId><error>xxx</error></artifactId>" +
                     "    <version><error>xxx</error></version>" +
                     "    <scope>system</scope>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testDoNotHighlightValidSystemScopeDependencies() throws Throwable {
    String libPath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar");

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>xxx</groupId>" +
                     "    <artifactId>xxx</artifactId>" +
                     "    <version>xxx</version>" +
                     "    <scope>system</scope>" +
                     "    <systemPath>" + libPath + "</systemPath>" +
                     "  </dependency>" +
                     "</dependencies>");
    checkHighlighting();
  }

  public void testResolvingSystemScopeDependenciesWithProperties() throws Throwable {
    String libPath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar");

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<properties>" +
                     "  <depPath>" + libPath + "</depPath>" +
                     "</properties>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>xxx</groupId>" +
                     "    <artifactId>xxx</artifactId>" +
                     "    <version><caret>xxx</version>" +
                     "    <scope>system</scope>" +
                     "    <systemPath>${depPath}</systemPath>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertResolved(myProjectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath)));
    checkHighlighting();
  }

  public void testCompletionSystemScopeDependenciesWithProperties() throws Throwable {
    String libPath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar");

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<properties>" +
                     "  <depDir>" + new File(libPath).getParent() + "</depDir>" +
                     "</properties>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>xxx</groupId>" +
                     "    <artifactId>xxx</artifactId>" +
                     "    <version>xxx</version>" +
                     "    <scope>system</scope>" +
                     "    <systemPath>${depDir}/<caret></systemPath>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom, "junit-4.0.jar");
  }

  public void testResolvingSystemScopeDependenciesFromSystemPath() throws Throwable {
    String libPath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar");

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>xxx</groupId>" +
                     "    <artifactId>xxx</artifactId>" +
                     "    <version>xxx</version>" +
                     "    <scope>system</scope>" +
                     "    <systemPath>" + libPath + "<caret></systemPath>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertResolved(myProjectPom, findPsiFile(LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath)));
    checkHighlighting();
  }

  public void testChooseFileIntentionForSystemDependency() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency><caret>" +
                     "    <groupId>xxx</groupId>" +
                     "    <artifactId>xxx</artifactId>" +
                     "    <version>xxx</version>" +
                     "    <scope>system</system>" +
                     "  </dependency>" +
                     "</dependencies>");

    IntentionAction action = getIntentionAtCaret("Choose File");
    assertNotNull(action);

    String libPath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.jar");
    final VirtualFile libFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(libPath);

    ((ChooseFileIntentionAction)((IntentionActionWrapper)action).getDelegate()).setFileChooser(new Producer<VirtualFile[]>() {
      @Override
      public VirtualFile[] produce() {
        return new VirtualFile[]{libFile};
      }
    });
    XmlCodeStyleSettings xmlSettings =
      CodeStyleSettingsManager.getInstance(myProject).getCurrentSettings().getCustomSettings(XmlCodeStyleSettings.class);

    int prevValue = xmlSettings.XML_TEXT_WRAP;
    try {
      // prevent file path from wrapping.
      xmlSettings.XML_TEXT_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
      myFixture.launchAction(action);
    }
    finally {
      xmlSettings.XML_TEXT_WRAP = prevValue;
      ((ChooseFileIntentionAction)((IntentionActionWrapper)action).getDelegate()).setFileChooser(null);
    }

    MavenDomProjectModel model = MavenDomUtil.getMavenDomProjectModel(myProject, myProjectPom);
    MavenDomDependency dep = model.getDependencies().getDependencies().get(0);

    assertEquals(findPsiFile(libFile), dep.getSystemPath().getValue());
  }

  public void testNoChooseFileIntentionForNonSystemDependency() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency><caret>" +
                     "    <groupId>xxx</groupId>" +
                     "    <artifactId>xxx</artifactId>" +
                     "    <version>xxx</version>" +
                     "    <scope>compile</system>" +
                     "  </dependency>" +
                     "</dependencies>");

    IntentionAction action = getIntentionAtCaret("Choose File");
    assertNull(action);
  }

  public void testTypeCompletion() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <type><caret></type>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom, "jar", "test-jar", "pom", "ear", "ejb", "ejb-client", "war", "bundle", "jboss-har", "jboss-sar", "maven-plugin");
  }

  public void testDoNotHighlightUnknownType() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId>junit</artifactId>" +
                     "    <version>4.0</version>" +
                     "    <type>xxx</type>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting(myProjectPom);
  }

  public void testScopeCompletion() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <scope><caret></scope>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom, "compile", "provided", "runtime", "test", "system");
  }

  public void testDoNotHighlightUnknownScopes() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId>junit</artifactId>" +
                     "    <version>4.0</version>" +
                     "    <scope>xxx</scope>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting(myProjectPom);
  }

  public void testPropertiesInScopes() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<properties>" +
                     "  <my.scope>compile</my.scope>" +
                     "</properties>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId>junit</artifactId>" +
                     "    <version>4.0</version>" +
                     "    <scope>${my.scope}</scope>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting(myProjectPom);
  }

  public void testDoesNotHighlightCorrectValues() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId>junit</artifactId>" +
                     "    <version>4.0</version>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testHighlightingArtifactIdAndVersionIfGroupIsUnknown() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId><error>unknown</error></groupId>" +
                     "    <artifactId><error>junit</error></artifactId>" +
                     "    <version><error>4.0</error></version>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testHighlightingArtifactAndVersionIfGroupIsEmpty() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId><error><</error>/groupId>" +
                     "    <artifactId><error>junit</error></artifactId>" +
                     "    <version><error>4.0</error></version>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testHighlightingVersionAndArtifactIfArtifactTheyAreFromAnotherGroup() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>jmock</groupId>" +
                     "    <artifactId><error>junit</error></artifactId>" +
                     "    <version><error>4.0</error></version>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testHighlightingVersionIfArtifactIsEmpty() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId><error><</error>/artifactId>" +
                     "    <version><error>4.0</error></version>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testHighlightingVersionIfArtifactIsUnknown() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId><error>unknown</error></artifactId>" +
                     "    <version><error>4.0</error></version>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testHighlightingVersionItIsFromAnotherGroup() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>jmock</groupId>" +
                     "    <artifactId>jmock</artifactId>" +
                     "    <version><error>4.0</error></version>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testHighlightingCoordinatesWithClosedTags() throws Throwable {
    if (ignore()) return;

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId/><error></error>" +
                     "    <artifactId/><error></error>" +
                     "    <version/><error></error>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testHandlingProperties() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<properties>" +
                     "  <dep.groupId>junit</dep.groupId>" +
                     "  <dep.artifactId>junit</dep.artifactId>" +
                     "  <dep.version>4.0</dep.version>" +
                     "</properties>");
    importProject();

    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     // properties are taken from loaded project

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>${dep.groupId}</groupId>" +
                     "    <artifactId>${dep.artifactId}</artifactId>" +
                     "    <version>${dep.version}</version>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testHandlingPropertiesWhenProjectIsNotYetLoaded() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<properties>" +
                     "  <dep.groupId>junit</dep.groupId>" +
                     "  <dep.artifactId>junit</dep.artifactId>" +
                     "  <dep.version>4.0</dep.version>" +
                     "</properties>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>${dep.groupId}</groupId>" +
                     "    <artifactId>${dep.artifactId}</artifactId>" +
                     "    <version>${dep.version}</version>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testDontHighlightProblemsInNonManagedPom1() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<properties>" +
                     "  <junitVersion>4.0</junitVersion>" +
                     "</properties>");

    VirtualFile m = createModulePom("m1",
                                    "<artifactId>m1</artifactId>" +

                                    "<parent>" +
                                    "  <groupId>test</groupId>" +
                                    "  <artifactId>project</artifactId>" +
                                    "  <version>1</version>" +
                                    "</parent>" +
                                    "<dependencies>" +
                                    " <dependency>" +
                                    " <groupId>junit</groupId>" +
                                    " <artifactId>junit</artifactId>" +
                                    " <version>${junitVersion}</version>" +
                                    " </dependency>" +
                                    "</dependencies>");

    importProject();

    checkHighlighting(m, true, false, true);
  }

  public void testDontHighlightProblemsInNonManagedPom2() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<properties>" +
                     "  <junitVersion>4.0</junitVersion>" +
                     "</properties>");

    VirtualFile m = createModulePom("m1",
                                    "<artifactId>m1</artifactId>" +

                                    "<parent>" +
                                    "  <groupId>test</groupId>" +
                                    "  <artifactId>project</artifactId>" +
                                    "  <version>1</version>" +
                                    "</parent>" +
                                    "<properties>" +
                                    " <aaa>${junitVersion}</aaa>" +
                                    "</properties>");

    importProject();
    checkHighlighting(m, true, false, true);
  }

  public void testUpdateIndicesIntention() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId><caret>xxx</groupId>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertNotNull(getIntentionAtCaret("Update Maven Indices"));
  }

  public void testExclusionCompletion() throws Exception {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId>junit</artifactId>" +
                     "    <exclusions>" +
                     "      <exclusion>" +
                     "        <groupId>jmock</groupId>" +
                     "        <artifactId><caret></artifactId>" +
                     "      </exclusion>" +
                     "    </exclusions>" +
                     "  </dependency>" +
                     "</dependencies>");

    assertCompletionVariants(myProjectPom, "jmock");
  }

  public void testDoNotHighlightUnknownExclusions() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId>junit</artifactId>" +
                     "    <exclusions>" +
                     "      <exclusion>" +
                     "        <groupId>foo</groupId>" +
                     "        <artifactId>bar</artifactId>" +
                     "      </exclusion>" +
                     "    </exclusions>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testExclusionHighlightingAbsentGroupId() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId>junit</artifactId>" +
                     "    <exclusions>" +
                     "      <<error descr=\"'groupId' child tag should be defined\">exclusion</error>>" +
                     "        <artifactId>jmock</artifactId>" +
                     "      </exclusion>" +
                     "    </exclusions>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }

  public void testExclusionHighlightingAbsentArtifactId() throws Throwable {
    createProjectPom("<groupId>test</groupId>" +
                     "<artifactId>project</artifactId>" +
                     "<version>1</version>" +

                     "<dependencies>" +
                     "  <dependency>" +
                     "    <groupId>junit</groupId>" +
                     "    <artifactId>junit</artifactId>" +
                     "    <exclusions>" +
                     "      <<error descr=\"'artifactId' child tag should be defined\">exclusion</error>>" +
                     "        <groupId>jmock</groupId>" +
                     "      </exclusion>" +
                     "    </exclusions>" +
                     "  </dependency>" +
                     "</dependencies>");

    checkHighlighting();
  }
}


text:
date: "2012-06-12 14:33:00 UTC"
published: true
title: "Making JavaScript testing in the browser not suck with Sinon.js (Part 1)"
authors:
  - "Carl Whittaker"
tags:
  - Testing
---

Writing tests for JavaScript is tough and often overlooked. I'm going to show you how to make it easier to write them with an awesome library called Sinon.js.

Getting started

There are several mature testing frameworks out there. I have my preference, but it's up to you to decide which framework meets your needs.

For your consideration:

QUnit

Mocha

Jasmine

Setting up

First we'll need to create a page to run our tests. We'll include the libraries we plan to use to write our tests.

In my examples I'm going to use QUnit simply because it's the framework I'm most familiar with and the tests are easy to read. Check out using QUnit for detailed setup instructions. You'll also need Sinon, so head over to sinonjs.org and download it along with the QUnit adapter.

Here's my test runner; I've included jQuery too because it makes it much easier to test the DOM.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Test Suite</title>
    <link rel="stylesheet" href="qunit.css" />
    <script src="jquery.min.js"></script>
    <script src="qunit.js"></script>
    <script src="sinon-1.3.4.js"></script>
    <script src="sinon-qunit.js"></script>
  </head>
  <body>
    <div id="qunit"></div>
    <div id="qunit-fixture"></div>
  </body>
</html>

If we run that in a browser we should see this:

Writing a simple test

Lets start with something very basic. We're going to write something that will let us build up a list of values and render them to a page. We could start with a test like this:

module('listView');

test('The user is presented with a list of added items', function () {
  document.getElementById('qunit-fixture').innerHTML = '<div id="list"></div>';
  var domList = document.getElementById('list'),
      list = listView(domList);

  list.addOne('javascript');
  list.render();

  equal(domList.innerHTML, 'javascript', 'A single value should be rendered');

  list.addOne('ftw');
  list.render();

  equal(domList.innerHTML, 'javascript ftw', 'A list of values should be rendered');
});

Here we're creating a fixture element and instantiating our new module. We're then exercising a function called addOne with a string and asserting that each time we call render the expected string is inserted into our element. Lets run our test and see it fail:

Now lets write some code to get this test to pass:

var listView = function (domEl) {
  var items = [];
  return {
    addOne: function (value) {
      items.push(value);
    },
    render: function () {
      domEl.innerHTML = items.join(' ');
    }
  };
};

There we go, our first test passes. Now onto more complicated matters.

Getting asynchronous

Now lets alter our listView module to load some data from the server. This presents us with two problems:

We don't want to request data from a real server. This would be slow and means we can't test our code in isolation.

The request could return at any time and our test doesn't know when to expect it.

Sinon.js to the rescue

Sinon is a collection of utterly essential testing tools that among other things enable you to deal with tricky asynchronous code and server requests.

Lets write a new test:

var xhr,
    requests,
    domList;

module('listView', {
  setup: function () {
    xhr = sinon.useFakeXMLHttpRequest()
    requests = [];
    xhr.onCreate = function (r) {
      requests.push(r);
    };
    document.getElementById('qunit-fixture').innerHTML = '<div id="list"></div>';
    domList = document.getElementById('list');
  },
  teardown: function () {
    xhr.restore();
  }
});

test('The list is populated from the server', function () {
  var list = listView(domList);
  list.fetch();

  equal(requests.length, 1, 'One XHR request should be made');

  requests[0].respond(200, {'Content-Type': 'application/json'}, '["XHR", "INNIT"]');

  equal(requests[0].url, '/path/to/list.json', 'A request to the correct URL should be made');

  list.render();

  equal(domList.innerHTML, 'XHR INNIT', 'The retrieved values should be rendered');
});

We've now defined a setup function for our test suite which replaces the native XMLHttpRequest with a fake one. This will intercept any attempt to communicate over XHR and allow us to define our own responses. Even better it will make our request synchronous since we're responding to our fake request immediately from inside our test; pretty cool.

Lets update listView and get that test to pass:

var listView = function (domEl) {
  var items = [];
  return {
    addOne: function (value) {
      items.push(value);
    },
    render: function () {
      domEl.innerHTML = items.join(' ');
    },
    fetch: function () {
      $.getJSON('/path/to/list.json', function (response) {
        items = response;
      });
    }
  };
};

Run the tests

Perfect.

Burning through time

When testing JavaScript animation or other asynchronous functionality based on timeouts and intervals you don't want to have to wait for them to finish in your tests.

Sinon.js solves this for you with fake timers. Sinon will replace the browsers' timing functions with it's own. This enables you to advance the clock manually and test what your code does in response.

Lets write a test to animate a simple cube:

test('cube is animated for 1 second', function () {
  document.getElementById('qunit-fixture').innerHTML = '<div id="cube"></div>';

  var domCube = document.getElementById('cube'),
      cube = animatedCube(domCube),
      clock = sinon.useFakeTimers();

  cube.animate();

  clock.tick(100);

  equal(domCube.style.left, '10px', 'Cube has moved 10px left after 100ms');

  clock.tick(100);

  equal(domCube.style.left, '20px', 'Cube has moved 20px left after 200ms');

  clock.tick(800);

  equal(domCube.style.left, '100px', 'Cube has moved 100px left after 1000ms');

  clock.tick(100);

  equal(domCube.style.left, '100px', 'Cube has stopped moving');

  clock.restore();
});

In this test we're telling Sinon to replace the browsers timers and then incrementally advancing the timer to interesting points in our animation and asserting that the cube is where we expect it to be.

And now lets make the test pass:

var animatedCube = function (domEl) {
  var x = 0,
      start,
      diff,
      interval,
      loop = function () {
        diff = Date.now() - start;
        x = Math.round((100 / 1000) * diff);
        domEl.style.left = x + 'px';
        if (x >= 100) clearInterval(interval);
      };

  domEl.style = 'width:10px;height:10px;background-color:red;position:relative';

  return {
    animate: function () {
      start = Date.now();
      interval = setInterval(loop, 10);
    }
  };
};

And now to run the tests.

Hopefully this has served as a useful introduction to effective JavaScript testing in the browser.

In the second part of this article I'll write about Sinon spies, mocks and stubs.


text:
#ifndef AXIS2_TRANSPORT_RECEIVER_H
#define AXIS2_TRANSPORT_RECEIVER_H

/**
 * @defgroup axis2_transport transport
 * @ingroup axis2
 * @{
 * @}
 */

/** @defgroup axis2_transport_receiver transport receiver
 * @ingroup axis2_transport
 * Description.
 * @{
 */

/**
 * @file axis2_transport_receiver.h
 * @brief Axis2 description transport receiver interface
 */

 #include <axis2_const.h>
 #include <axutil_error.h>
 #include <axis2_defines.h>
 #include <axutil_env.h>
 #include <axutil_allocator.h>
 #include <axis2_endpoint_ref.h>
 #include <axis2_ctx.h>
 #include <axis2_conf_ctx.h>

#ifdef __cplusplus
extern "C"
{
#endif

    struct axis2_conf_ctx;
    struct axis2_transport_in_desc;

    /** Type name for axis2_transport_receiver */
    typedef struct axis2_transport_receiver axis2_transport_receiver_t;

    /** Type name for axis2_transport_receiver_ops */
    typedef struct axis2_transport_receiver_ops axis2_transport_receiver_ops_t;

    /**
     * @brief Description Transport Receiver ops struct
     * Encapsulator struct for ops of axis2_transport_receiver
     */
    struct axis2_transport_receiver_ops
    {

        /**
         * @param transport_receiver pointer to transport receiver
         * @param env pointer to environment struct
         * @param conf_ctx pointer to configuration context
         * @param intrasport_in pointer to transport_in
         */
        axis2_status_t(AXIS2_CALL * init)(
            axis2_transport_receiver_t * transport_receiver,
            const axutil_env_t * env,
            struct axis2_conf_ctx * conf_ctx,
            struct axis2_transport_in_desc * transport_in);

        /**
         * @param transport_receiver
         * @param env pointer to environment struct
         */
        axis2_status_t(AXIS2_CALL * start)(
            axis2_transport_receiver_t * transport_receiver,
            const axutil_env_t * env);

        /**
         * @param tranport_receiver pointer to transport receiver
         * @param env pointer to environment struct
         * @param svc_name pointer to service name
         */
        axis2_endpoint_ref_t *(AXIS2_CALL * get_reply_to_epr)(
            axis2_transport_receiver_t * transport_receiver,
            const axutil_env_t * env,
            const axis2_char_t * svc_name);

		     /**
         * @param tranport_receiver pointer to transport receiver
         * @param env pointer to environment struct
         * @param svc_name pointer to service name
         */
        axis2_endpoint_ref_t *(AXIS2_CALL * get_epr_for_service)(
            axis2_transport_receiver_t * transport_receiver,
            const axutil_env_t * env,
            const axis2_char_t * svc_name);

				     /**
         * @param tranport_receiver pointer to transport receiver
         * @param env pointer to environment struct
         * @param svc_name pointer to service name
         */
         axis2_char_t *(AXIS2_CALL * get_server_ip)(
            axis2_transport_receiver_t * transport_receiver,
            const axutil_env_t * env);

				     /**
         * @param tranport_receiver pointer to transport receiver
         * @param env pointer to environment struct
         * @param svc_name pointer to service name
         */
        void (AXIS2_CALL * set_server_ip)(
            axis2_transport_receiver_t * transport_receiver,
            const axutil_env_t * env,
             axis2_char_t * ip);

        /**
         * @param server pointer to server
         * @param env pointer to environment struct
         */
        struct axis2_conf_ctx *(AXIS2_CALL * get_conf_ctx)(
            axis2_transport_receiver_t * server,
            const axutil_env_t * env);

        /**
         * @param server pointer to server
         * @param env pointer to environment struct
         */
        axis2_bool_t(AXIS2_CALL * is_running)(
            axis2_transport_receiver_t * server,
            const axutil_env_t * env);

        void(AXIS2_CALL * set_is_application_client_side)(
            axis2_transport_receiver_t * server,
            const axutil_env_t * env,
            axis2_bool_t is_application_client_side);

        /**
         * @param transport_receiver pointer to transport receiver
         * @param env pointer to environment struct
         */
        axis2_status_t(AXIS2_CALL * stop)(
            axis2_transport_receiver_t * transport_receiver,
            const axutil_env_t * env);

        /**
         * De-allocate memory
         * @param transport_receiver pointer to transport receiver
         * @param env pointer to environment struct
         */
        void(AXIS2_CALL * free)(
            axis2_transport_receiver_t * transport_receiver,
            const axutil_env_t * env);

    };

    /**
     * @brief Transport Receiver  struct
     */
    struct axis2_transport_receiver
    {
        const axis2_transport_receiver_ops_t *ops;
    };

    /** Frees the transport receiver.
     @sa axis2_transport_receiver#free */
    AXIS2_EXTERN void AXIS2_CALL
    axis2_transport_receiver_free(
        axis2_transport_receiver_t * transport_receiver,
        const axutil_env_t * env);

    /** Initialize the transport receiver.
     @sa axis2_transport_receiver#init */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axis2_transport_receiver_init(
        axis2_transport_receiver_t * transport_receiver,
        const axutil_env_t * env,
        struct axis2_conf_ctx *conf_ctx,
        struct axis2_transport_in_desc *transport_in);

    /** Start
     @sa axis2_transport_receiver#start */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axis2_transport_receiver_start(
        axis2_transport_receiver_t * transport_receiver,
        const axutil_env_t * env);

    /** Stop.
     @sa axis2_transport_receiver#stop */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axis2_transport_receiver_stop(
        axis2_transport_receiver_t * transport_receiver,
        const axutil_env_t * env);

    /** Get reply to epr.
     @sa axis2_transport_receiver#get_reply_to_epr */
    AXIS2_EXTERN axis2_endpoint_ref_t *AXIS2_CALL
    axis2_transport_receiver_get_reply_to_epr(
        axis2_transport_receiver_t * transport_receiver,
        const axutil_env_t * env,
        const axis2_char_t * svc_name);

    /** Get conf ctx.
     @sa axis2_transport_receiver#get_conf_ctx */
    AXIS2_EXTERN struct axis2_conf_ctx *AXIS2_CALL
    axis2_transport_receiver_get_conf_ctx(
        axis2_transport_receiver_t * transport_receiver,
        const axutil_env_t * env);

    /** Is running.
     @sa axis2_transport_receiver#is_running */
    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
    axis2_transport_receiver_is_running(
        axis2_transport_receiver_t * transport_receiver,
        const axutil_env_t * env);

    AXIS2_EXTERN void AXIS2_CALL
    axis2_transport_receiver_set_is_application_client_side(
        axis2_transport_receiver_t * transport_receiver,
        const axutil_env_t * env,
        axis2_bool_t is_application_client_side);

	AXIS2_EXTERN axis2_endpoint_ref_t* AXIS2_CALL
		axis2_transport_receiver_get_epr_for_service(axis2_transport_receiver_t *transport_receiver,
		const axutil_env_t *env,
		const axis2_char_t *svc_name);

	AXIS2_EXTERN  axis2_char_t* AXIS2_CALL
	axis2_transport_receiver_get_server_ip(
	axis2_transport_receiver_t *transport_receiver,
	const axutil_env_t *env);

	AXIS2_EXTERN void AXIS2_CALL
	axis2_transport_receiver_set_server_ip(
	axis2_transport_receiver_t *transport_receiver,
	const axutil_env_t *env,
	 axis2_char_t *serverip);

    /** @} */

#ifdef __cplusplus
}
#endif
#endif                          /* AXIS2_TRANSPORT_RECEIVER_H */


text:
/*	$NetBSD: test_ntlm.c,v 1.1.1.1 2011/04/13 18:14:44 elric Exp $	*/

/*
 * Copyright (c) 2006 - 2008 Kungliga Tekniska Högskolan
 * (Royal Institute of Technology, Stockholm, Sweden).
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * 3. Neither the name of KTH nor the names of its contributors may be
 *    used to endorse or promote products derived from this software without
 *    specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "config.h"

#include <krb5/roken.h>
#include <stdio.h>
#include <gssapi/gssapi.h>
#include <err.h>
#include <krb5/getarg.h>
#include "test_common.h"

#include <krb5/krb5.h>
#include <krb5/heimntlm.h>

static int
test_libntlm_v1(int flags)
{
    const char *user = "foo",
	*domain = "mydomain",
	*password = "digestpassword";
    OM_uint32 maj_stat, min_stat;
    gss_ctx_id_t ctx = GSS_C_NO_CONTEXT;
    gss_buffer_desc input, output;
    struct ntlm_type1 type1;
    struct ntlm_type2 type2;
    struct ntlm_type3 type3;
    struct ntlm_buf data;
    krb5_error_code ret;
    gss_name_t src_name = GSS_C_NO_NAME;

    memset(&type1, 0, sizeof(type1));
    memset(&type2, 0, sizeof(type2));
    memset(&type3, 0, sizeof(type3));

    type1.flags = NTLM_NEG_UNICODE|NTLM_NEG_TARGET|NTLM_NEG_NTLM|flags;
    type1.domain = strdup(domain);
    type1.hostname = NULL;
    type1.os[0] = 0;
    type1.os[1] = 0;

    ret = heim_ntlm_encode_type1(&type1, &data);
    if (ret)
	errx(1, "heim_ntlm_encode_type1");

    input.value = data.data;
    input.length = data.length;

    output.length = 0;
    output.value = NULL;

    maj_stat = gss_accept_sec_context(&min_stat,
				      &ctx,
				      GSS_C_NO_CREDENTIAL,
				      &input,
				      GSS_C_NO_CHANNEL_BINDINGS,
				      NULL,
				      NULL,
				      &output,
				      NULL,
				      NULL,
				      NULL);
    free(data.data);
    if (GSS_ERROR(maj_stat))
	errx(1, "accept_sec_context v1: %s",
	     gssapi_err(maj_stat, min_stat, GSS_C_NO_OID));

    if (output.length == 0)
	errx(1, "output.length == 0");

    data.data = output.value;
    data.length = output.length;

    ret = heim_ntlm_decode_type2(&data, &type2);
    if (ret)
	errx(1, "heim_ntlm_decode_type2");

    gss_release_buffer(&min_stat, &output);

    type3.flags = type2.flags;
    type3.username = rk_UNCONST(user);
    type3.targetname = type2.targetname;
    type3.ws = rk_UNCONST("workstation");

    {
	struct ntlm_buf key;

	heim_ntlm_nt_key(password, &key);

	heim_ntlm_calculate_ntlm1(key.data, key.length,
				  type2.challenge,
				  &type3.ntlm);

	if (flags & NTLM_NEG_KEYEX) {
	    struct ntlm_buf sessionkey;
	    heim_ntlm_build_ntlm1_master(key.data, key.length,
					 &sessionkey,
				     &type3.sessionkey);
	    free(sessionkey.data);
	}
	free(key.data);
    }

    ret = heim_ntlm_encode_type3(&type3, &data);
    if (ret)
	errx(1, "heim_ntlm_encode_type3");

    input.length = data.length;
    input.value = data.data;

    maj_stat = gss_accept_sec_context(&min_stat,
				      &ctx,
				      GSS_C_NO_CREDENTIAL,
				      &input,
				      GSS_C_NO_CHANNEL_BINDINGS,
				      &src_name,
				      NULL,
				      &output,
				      NULL,
				      NULL,
				      NULL);
    free(input.value);
    if (maj_stat != GSS_S_COMPLETE)
	errx(1, "accept_sec_context v1 2 %s",
	     gssapi_err(maj_stat, min_stat, GSS_C_NO_OID));

    gss_release_buffer(&min_stat, &output);
    gss_delete_sec_context(&min_stat, &ctx, NULL);

    if (src_name == GSS_C_NO_NAME)
	errx(1, "no source name!");

    gss_display_name(&min_stat, src_name, &output, NULL);

    printf("src_name: %.*s\n", (int)output.length, (char*)output.value);

    gss_release_name(&min_stat, &src_name);
    gss_release_buffer(&min_stat, &output);

    return 0;
}

static int
test_libntlm_v2(int flags)
{
    const char *user = "foo",
	*domain = "mydomain",
	*password = "digestpassword";
    OM_uint32 maj_stat, min_stat;
    gss_ctx_id_t ctx = GSS_C_NO_CONTEXT;
    gss_buffer_desc input, output;
    struct ntlm_type1 type1;
    struct ntlm_type2 type2;
    struct ntlm_type3 type3;
    struct ntlm_buf data;
    krb5_error_code ret;

    memset(&type1, 0, sizeof(type1));
    memset(&type2, 0, sizeof(type2));
    memset(&type3, 0, sizeof(type3));

    type1.flags = NTLM_NEG_UNICODE|NTLM_NEG_NTLM|flags;
    type1.domain = strdup(domain);
    type1.hostname = NULL;
    type1.os[0] = 0;
    type1.os[1] = 0;

    ret = heim_ntlm_encode_type1(&type1, &data);
    if (ret)
	errx(1, "heim_ntlm_encode_type1");

    input.value = data.data;
    input.length = data.length;

    output.length = 0;
    output.value = NULL;

    maj_stat = gss_accept_sec_context(&min_stat,
				      &ctx,
				      GSS_C_NO_CREDENTIAL,
				      &input,
				      GSS_C_NO_CHANNEL_BINDINGS,
				      NULL,
				      NULL,
				      &output,
				      NULL,
				      NULL,
				      NULL);
    free(data.data);
    if (GSS_ERROR(maj_stat))
	errx(1, "accept_sec_context v2 %s",
	     gssapi_err(maj_stat, min_stat, GSS_C_NO_OID));

    if (output.length == 0)
	errx(1, "output.length == 0");

    data.data = output.value;
    data.length = output.length;

    ret = heim_ntlm_decode_type2(&data, &type2);
    if (ret)
	errx(1, "heim_ntlm_decode_type2");

    type3.flags = type2.flags;
    type3.username = rk_UNCONST(user);
    type3.targetname = type2.targetname;
    type3.ws = rk_UNCONST("workstation");

    {
	struct ntlm_buf key;
	unsigned char ntlmv2[16];

	heim_ntlm_nt_key(password, &key);

	heim_ntlm_calculate_ntlm2(key.data, key.length,
				  user,
				  type2.targetname,
				  type2.challenge,
				  &type2.targetinfo,
				  ntlmv2,
				  &type3.ntlm);
	free(key.data);

	if (flags & NTLM_NEG_KEYEX) {
	    struct ntlm_buf sessionkey;
	    heim_ntlm_build_ntlm1_master(ntlmv2, sizeof(ntlmv2),
					 &sessionkey,
					 &type3.sessionkey);
	    free(sessionkey.data);
	}
    }

    ret = heim_ntlm_encode_type3(&type3, &data);
    if (ret)
	errx(1, "heim_ntlm_encode_type3");

    input.length = data.length;
    input.value = data.data;

    maj_stat = gss_accept_sec_context(&min_stat,
				      &ctx,
				      GSS_C_NO_CREDENTIAL,
				      &input,
				      GSS_C_NO_CHANNEL_BINDINGS,
				      NULL,
				      NULL,
				      &output,
				      NULL,
				      NULL,
				      NULL);
    free(input.value);
    if (maj_stat != GSS_S_COMPLETE)
	errx(1, "accept_sec_context v2 2 %s",
	     gssapi_err(maj_stat, min_stat, GSS_C_NO_OID));

    gss_delete_sec_context(&min_stat, &ctx, NULL);

    return 0;
}

static int version_flag = 0;
static int help_flag	= 0;

static struct getargs args[] = {
    {"version",	0,	arg_flag,	&version_flag, "print version", NULL },
    {"help",	0,	arg_flag,	&help_flag,  NULL, NULL }
};

static void
usage (int ret)
{
    arg_printusage (args, sizeof(args)/sizeof(*args),
		    NULL, "");
    exit (ret);
}

int
main(int argc, char **argv)
{
    int ret = 0, optind = 0;

    setprogname(argv[0]);

    if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optind))
	usage(1);

    if (help_flag)
	usage (0);

    if(version_flag){
	print_version(NULL);
	exit(0);
    }

    argc -= optind;
    argv += optind;

    ret += test_libntlm_v1(0);
    ret += test_libntlm_v1(NTLM_NEG_KEYEX);

    ret += test_libntlm_v2(0);
    ret += test_libntlm_v2(NTLM_NEG_KEYEX);

    return 0;
}


text:
layout: archive_smaller_font
author_profile: true
title: "Call for Papers"
---

9th International Symposium on Search Based Software Engineering (SSBSE 2017)
co-located with ESEC/FSE'17 Paderborn, Germany, September 9-11, 2017

____

**Key Dates**

TUTORIALS:

- Tutorial Proposals                      February 14, 2017
- Tutorials Selected                      February 28, 2017
- To propose a tutorial, please email ssbse2017@easychair.org

RESEARCH PAPER TRACK:

- Abstract submission                      March 31, 2017
- Paper Submission                            April 7, 2017
- Notification                                     May 10, 2017
- Camera Ready                                June 7, 2017
- Submission site: https://easychair.org/conferences/?conf=ssbse2017

 SHORT PAPER TRACK:

 - Submission                                    May 21, 2017
 - Notification                                    June 4, 2017
 - Camera ready:                                   June 11, 2017
 - Submission site: https://easychair.org/conferences/?conf=ssbse2017 and select the Student and Short Paper Track option

 STUDENT TRACK:

 - Submission                                    May 21, 2017
 - Notification                                    June 4, 2017
 - Camera ready:                                   June 11, 2017
  - Submission site: https://easychair.org/conferences/?conf=ssbse2017 and select the Student and Short Paper Track option

 SBSE CHALLENGE TRACK:

 - Submission                                    May 25, 2017
 - Notification                                    June 4, 2017
 - Camera ready:                                   June 11, 2017
 - Submission site: https://easychair.org/conferences/?conf=ssbse2017challenge

____

**Research Paper Track**

We invite the submission of high quality papers describing novel and original work in all areas of Search-Based Software Engineering including, but not limited to

-  applications of SBSE to novel problems,
- theoretical analyses of search algorithms for software engineering,
- rigorous empirical evaluations of SBSE techniques,
- reports of industrial experiences.

SSBSE welcomes not only applications from throughout the software engineering lifecycle but also a broad range of search methods ranging from:

- exact Operational Research techniques to
- nature-inspired algorithms and simulated annealing.

We particularly encourage papers that report on software engineering applications to which SBSE has not been applied before.

Research papers must have up to 15 pages in length, including all text, figures, references and appendices.

____

**Short Paper Track**

We also invite short papers presenting new ideas, tools, experience reports, or novel techniques and ideas, which will be included in the proceedings and presented at the symposium. Papers submitted to this track should not exceed 6 pages in length using the regular symposium format.

____

**Student Track**

We also invite students to submit papers to a special Student track. This track gives students the opportunity to showcase their SBSE research and receive feedback from senior members of the SBSE community. Papers submitted to this track should not exceed 6 pages in length using the regular symposium format. To be eligible, papers should be primarily the work of students that have not yet completed their studies. The paper may have co-authors who are not students but the student author is expected to present the paper at the symposium.

____

**SBSE Challenge Track**

We challenge everyone interested in SBSE to apply tools, techniques, and algorithms to our selected problems. We want you to apply your SBSE expertise to do interesting things to or with the software and uncover interesting things related to it. The best competition entries will be awarded special prizes. Challenge papers should not exceed 6 pages in length using the regular symposium format. More details about the track will be announced on the website.

____

**Tutorials**

2 page proposals for 1 hour tutorials covering state-of-the-art SBSE methods. Proposals must describe what will be presented and why this might be of interest to this community. Proposals will be selected on their novelty, technical content, track record of the presenter and, ideally, degree of interactivity with the audience.

____

**Transfer talks**

Invited talks from authors publishing innovative work relevant to SBSE, originally presented at other forums. To nominate speakers for such talks, please email ssbse2017@easychair.org.

____

**Conference Proceedings**

Accepted papers will be published in a volume of the Springer Lecture Notes in Computer Science series (LNCS).

**Best Paper Awards and Travel Grants**

Research and Student papers accepted for presentation at SSBSE 2017 will be considered for prizes. More details about prizes and travel grants will be announced on the website.

**Special Section in IST for Best Papers**

Following from the conference, a selection of best papers will be invited to submit extended versions for tentative publication in a Special Section of the journal of Information and Software Technology published by Elsevier http://www.elsevier.com/locate/infsof.

**GENERAL INFORMATION AND FORMAT**

Papers must not have been previously published, or be in consideration for, any journal, book, or other conference.

Papers must be formatted according to the LNCS instructions (http://www.springer.com/lncs). In addition to those instructions, please consider that SSBSE is performing double-blind review of all submissions, but those for the SBSE Challenge track (i.e., authors will not be identified to reviewers, and reviewers will not be identified to authors; see here for more information). We therefore ask that authors anonymize their submissions:

1. Omit author and institutional information from the author list on the title page, as well as on all paper headers. Unfortunately, the llncs format does not provide an easy blinding mechanism. We thus recommend that you replace author and affiliation info with "Authors/institution suppressed for blind review" so that the header spacing is maintained relative to the page limit.
2. Remove clues that directly identify the authors from the main paper text.
3. Anonymize reference to other work by the authors by citing the authors in the third person. For instance, "Foo and Bar previously proposed the Baz technique [1]" instead of "In previous work, we proposed the Baz technique [1]." We prefer this technique for publications that are readily available and appear in mainstream venues. If the work being cited is in press, it may be cited as "Anonymous."

Authors of accepted papers will be able to modify the text to de-anonymize for the camera-ready version of their papers. Feel free to contact the PC chairs (Tim Menzies and Justyna Petke) if you have any questions or concerns.

Submission site: https://easychair.org/conferences/?conf=ssbse2017


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
J. Parasit. 93(3): 655-660 (2000)

#### Original name
Kabatana J. Lom, I. Dyková & K. Tonguthai

### Remarks
null


text:
namespace ResotelApp.Migrations
{
    using System.Data.Entity.Migrations;

    public partial class AddRommsToBooking : DbMigration
    {
        public override void Up()
        {
        }

        public override void Down()
        {
        }
    }
}


text:
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import Alert from './Alert';

describe('<Alert>', () => {
  it('Should output a alert with message', () => {
    // when
    render(
      <Alert>
        Message
      </Alert>
    );

    // then
    expect(screen.getByRole('alert')).toBeInTheDocument();
    expect(screen.getByText('Message')).toBeInTheDocument();
  });

  it('Should have bsType by default', () => {
    // when
    render(
      <Alert>
        Message
      </Alert>
    );

    // then
    expect(screen.getByRole('alert')).toHaveClass('alert-info');
  });

  it('Should have dismissable style with onDismiss', () => {
    // when
    render(
      <Alert onDismiss={jest.fn()}>
        Message
      </Alert>
    );

    // then
    expect(screen.getByRole('alert')).toHaveClass('alert-dismissable');
  });

  it('Should call onDismiss callback on dismiss click', () => {
    // given
    const onDismiss = jest.fn();
    render(
      <Alert onDismiss={onDismiss} closeLabel="close">
        Message
      </Alert>
    );
    expect(onDismiss).not.toBeCalled();

    // when
    userEvent.click(screen.getByRole('button', { name: 'close' }));

    // then
    expect(onDismiss).toBeCalled();
  });

  it('Should have a default bsStyle class', () => {
    // when
    render(<Alert>Message</Alert>);

    // then
    expect(screen.getByRole('alert')).toHaveClass('alert-info');
  });

  it('Should have use bsStyle class', () => {
    // when
    render(<Alert bsStyle="danger">Message</Alert>);

    // then
    expect(screen.getByRole('alert')).toHaveClass('alert-danger');
  });

  describe('Web Accessibility', () => {
    it('Should call onDismiss callback when the sr-only dismiss link is activated', () => {
      // given
      const onDismiss = jest.fn();
      render(<Alert onDismiss={onDismiss}>Message</Alert>);
      expect(onDismiss).not.toBeCalled();

      // when
      userEvent.click(screen.getByRole('button', { name: 'Close alert' }));

      // then
      expect(onDismiss).toBeCalled();
    });
  });
});


text:
package com.android.supervolley;

import okio.Buffer;

class HttpUrl {

    private static final char[] HEX_DIGITS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

    static String canonicalize(String input, int pos, int limit, String encodeSet, boolean alreadyEncoded, boolean strict, boolean plusIsSpace, boolean asciiOnly) {
        int codePoint;
        for (int i = pos; i < limit; i += Character.charCount(codePoint)) {
            codePoint = input.codePointAt(i);
            if (codePoint < 32 || codePoint == 127 || codePoint >= 128 && asciiOnly || encodeSet.indexOf(codePoint) != -1 || codePoint == 37 && (!alreadyEncoded || strict && !percentEncoded(input, i, limit)) || codePoint == 43 && plusIsSpace) {
                Buffer out = new Buffer();
                out.writeUtf8(input, pos, i);
                canonicalize(out, input, i, limit, encodeSet, alreadyEncoded, strict, plusIsSpace, asciiOnly);
                return out.readUtf8();
            }
        }

        return input.substring(pos, limit);
    }

    static void canonicalize(Buffer out, String input, int pos, int limit, String encodeSet, boolean alreadyEncoded, boolean strict, boolean plusIsSpace, boolean asciiOnly) {
        Buffer utf8Buffer = null;

        int codePoint;
        for (int i = pos; i < limit; i += Character.charCount(codePoint)) {
            codePoint = input.codePointAt(i);
            if (!alreadyEncoded || codePoint != 9 && codePoint != 10 && codePoint != 12 && codePoint != 13) {
                if (codePoint == 43 && plusIsSpace) {
                    out.writeUtf8(alreadyEncoded ? "+" : "%2B");
                } else if (codePoint >= 32 && codePoint != 127 && (codePoint < 128 || !asciiOnly) && encodeSet.indexOf(codePoint) == -1 && (codePoint != 37 || alreadyEncoded && (!strict || percentEncoded(input, i, limit)))) {
                    out.writeUtf8CodePoint(codePoint);
                } else {
                    if (utf8Buffer == null) {
                        utf8Buffer = new Buffer();
                    }

                    utf8Buffer.writeUtf8CodePoint(codePoint);

                    while (!utf8Buffer.exhausted()) {
                        int b = utf8Buffer.readByte() & 255;
                        out.writeByte(37);
                        out.writeByte(HEX_DIGITS[b >> 4 & 15]);
                        out.writeByte(HEX_DIGITS[b & 15]);
                    }
                }
            }
        }

    }

    static String canonicalize(String input, String encodeSet, boolean alreadyEncoded, boolean strict, boolean plusIsSpace, boolean asciiOnly) {
        return canonicalize(input, 0, input.length(), encodeSet, alreadyEncoded, strict, plusIsSpace, asciiOnly);
    }

    static String percentDecode(String encoded, boolean plusIsSpace) {
        return percentDecode(encoded, 0, encoded.length(), plusIsSpace);
    }

    static String percentDecode(String encoded, int pos, int limit, boolean plusIsSpace) {
        for (int i = pos; i < limit; ++i) {
            char c = encoded.charAt(i);
            if (c == 37 || c == 43 && plusIsSpace) {
                Buffer out = new Buffer();
                out.writeUtf8(encoded, pos, i);
                percentDecode(out, encoded, i, limit, plusIsSpace);
                return out.readUtf8();
            }
        }

        return encoded.substring(pos, limit);
    }

    static void percentDecode(Buffer out, String encoded, int pos, int limit, boolean plusIsSpace) {
        int codePoint;
        for (int i = pos; i < limit; i += Character.charCount(codePoint)) {
            codePoint = encoded.codePointAt(i);
            if (codePoint == 37 && i + 2 < limit) {
                int d1 = decodeHexDigit(encoded.charAt(i + 1));
                int d2 = decodeHexDigit(encoded.charAt(i + 2));
                if (d1 != -1 && d2 != -1) {
                    out.writeByte((d1 << 4) + d2);
                    i += 2;
                    continue;
                }
            } else if (codePoint == 43 && plusIsSpace) {
                out.writeByte(32);
                continue;
            }

            out.writeUtf8CodePoint(codePoint);
        }

    }

    static boolean percentEncoded(String encoded, int pos, int limit) {
        return pos + 2 < limit && encoded.charAt(pos) == 37 && decodeHexDigit(encoded.charAt(pos + 1)) != -1 && decodeHexDigit(encoded.charAt(pos + 2)) != -1;
    }

    static int decodeHexDigit(char c) {
        return c >= 48 && c <= 57 ? c - 48 : (c >= 97 && c <= 102 ? c - 97 + 10 : (c >= 65 && c <= 70 ? c - 65 + 10 : -1));
    }
}