aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-testing-harness/src
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-testing-harness/src')
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/MoreConditions.java71
-rw-r--r--sonar-testing-harness/src/test/java/org/sonar/test/MoreConditionsTest.java109
2 files changed, 0 insertions, 180 deletions
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/MoreConditions.java b/sonar-testing-harness/src/main/java/org/sonar/test/MoreConditions.java
deleted file mode 100644
index 16681d6f88f..00000000000
--- a/sonar-testing-harness/src/main/java/org/sonar/test/MoreConditions.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.test;
-
-import com.google.common.base.CharMatcher;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.fest.assertions.Condition;
-
-import java.util.Collection;
-
-/**
- * Conditions for use with FestAssert.
- */
-public final class MoreConditions {
- private static final CharMatcher EOLS = CharMatcher.anyOf("\n\r");
-
- private MoreConditions() {
- // static utility class
- }
-
- public static Condition<String> equalsIgnoreEOL(String text) {
- final String strippedText = EOLS.removeFrom(text);
-
- return new Condition<String>() {
- @Override
- public boolean matches(String value) {
- return EOLS.removeFrom(value).equals(strippedText);
- }
- }.as("equal to " + strippedText);
- }
-
- public static Condition<Collection<?>> contains(final Object expected) {
- return new Condition<Collection<?>>() {
- @Override
- public boolean matches(Collection<?> collection) {
- for (Object actual : collection) {
- if (EqualsBuilder.reflectionEquals(expected, actual)) {
- return true;
- }
- }
- return false;
- }
- };
- }
-
- public static Condition<Object> reflectionEqualTo(final Object expected) {
- return new Condition<Object>() {
- @Override
- public boolean matches(Object actual) {
- return EqualsBuilder.reflectionEquals(expected, actual);
- }
- };
- }
-}
diff --git a/sonar-testing-harness/src/test/java/org/sonar/test/MoreConditionsTest.java b/sonar-testing-harness/src/test/java/org/sonar/test/MoreConditionsTest.java
deleted file mode 100644
index d741713daad..00000000000
--- a/sonar-testing-harness/src/test/java/org/sonar/test/MoreConditionsTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.test;
-
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import static org.sonar.test.MoreConditions.reflectionEqualTo;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.sonar.test.MoreConditions.contains;
-import static org.sonar.test.MoreConditions.equalsIgnoreEOL;
-
-public class MoreConditionsTest {
- @Test
- public void should_compare_equals_texts() {
- assertThat("TEXT").satisfies(equalsIgnoreEOL("TEXT"));
- }
-
- @Test
- public void should_ignore_line_feeds_and_carriage_returns() {
- assertThat("BEFORE\nAFTER").satisfies(equalsIgnoreEOL("BEFOREAFTER"));
- assertThat("BEFORE\rAFTER").satisfies(equalsIgnoreEOL("BEFOREAFTER"));
- assertThat("BEFORE\n\rAFTER").satisfies(equalsIgnoreEOL("BEFOREAFTER"));
- assertThat("BEFOREAFTER").satisfies(equalsIgnoreEOL("BEFORE\n\rAFTER"));
- }
-
- @Test
- public void should_refuse_different_values() {
- assertThat("TEXT").doesNotSatisfy(equalsIgnoreEOL("DIFFERENT"));
- }
-
- @Test
- public void should_accept_empty_values() {
- assertThat("").satisfies(equalsIgnoreEOL(""));
- assertThat("").satisfies(equalsIgnoreEOL("\n\r"));
- assertThat("\n\r").satisfies(equalsIgnoreEOL(""));
- }
-
- @Test
- public void should_find_value_in_collection() {
- Collection<String> collection = Arrays.asList("ONE", "TWO");
-
- assertThat(collection).satisfies(contains("ONE"));
- assertThat(collection).satisfies(contains("TWO"));
- assertThat(collection).doesNotSatisfy(contains("THREE"));
- }
-
- @Test
- public void should_find_value_in_collection_using_reflection() {
- Collection<Bean> collection = Arrays.asList(
- new Bean("key1", "value1"),
- null,
- new Bean("key2", "value2"));
-
- assertThat(collection).satisfies(contains(new Bean("key1", "value1")));
- assertThat(collection).satisfies(contains(new Bean("key2", "value2")));
- assertThat(collection).doesNotSatisfy(contains(new Bean("key1", "value2")));
- assertThat(collection).doesNotSatisfy(contains(new Bean("key2", "value1")));
- assertThat(collection).doesNotSatisfy(contains(new Bean("", "")));
- }
-
- @Test
- public void should_compare_using_reflection() {
- Bean bean1 = new Bean("key1", "value1");
- Bean bean2 = new Bean("key2", "value2");
-
- assertThat(bean1).is(reflectionEqualTo(bean1));
- assertThat(bean2).is(reflectionEqualTo(bean2));
- assertThat(bean1).isNot(reflectionEqualTo(bean2));
- assertThat(bean2).isNot(reflectionEqualTo(bean1));
- assertThat(bean1).isNot(reflectionEqualTo(null));
- assertThat(bean2).isNot(reflectionEqualTo(null));
- assertThat(bean1).isNot(reflectionEqualTo(new Object()));
- assertThat(bean2).isNot(reflectionEqualTo(new Object()));
- assertThat(bean1).isNot(reflectionEqualTo(new Bean("key1", "value2")));
- assertThat(bean1).isNot(reflectionEqualTo(new Bean("key2", "value1")));
- assertThat(bean1).isNot(reflectionEqualTo(new Bean("", "")));
- }
-
- static final class Bean {
- final String key;
- final String value;
-
- Bean(String key, String value) {
- this.key = key;
- this.value = value;
- }
- }
-}