Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremie Bresson2013-05-06 06:24:45 +0000
committerGerrit Code Review @ Eclipse.org2013-05-06 08:16:43 +0000
commit292726cde7a7703e706e3228b23ac1f4c9e9248c (patch)
treead3da08bb628c867d4cbfee05d4c4893a0ac97ae
parent5276e77a09e7f17ccb612964e81c598f2c4e3b5d (diff)
downloadorg.eclipse.scout.rt-292726cde7a7703e706e3228b23ac1f4c9e9248c.tar.gz
org.eclipse.scout.rt-292726cde7a7703e706e3228b23ac1f4c9e9248c.tar.xz
org.eclipse.scout.rt-292726cde7a7703e706e3228b23ac1f4c9e9248c.zip
Bug 402301: Migration: UI Independent tests
* add fragment: org.eclipse.scout.rt.testing.shared.test * some corrections from review https://bugs.eclipse.org/bugs/show_bug.cgi?id=402301 Change-Id: Id2ed6ff954884e20a1e13ac27c8822eb2ea6c321
-rw-r--r--org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/basic/table/columns/ColumnAutoResizeTest.java3
-rw-r--r--org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/shared/data/form/FormDataImportWithTemplatesTest.java (renamed from org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/shared/data/form/ImportFormDataWithTemplatesTest.java)2
-rw-r--r--org.eclipse.scout.rt.parent/pom.xml1
-rw-r--r--org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/CodeLookupCallTest.java265
-rw-r--r--org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/fixture/ILegacyCodeLookupCallVisitor.java22
-rw-r--r--org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/fixture/LegacyCodeLookupCall.java243
-rw-r--r--org.eclipse.scout.rt.testing.server.test/src/org/eclipse/scout/rt/testing/server/runner/ScoutServerTestRunnerTransactionBehaviorTest.java46
-rw-r--r--org.eclipse.scout.rt.testing.shared.test/.classpath7
-rw-r--r--org.eclipse.scout.rt.testing.shared.test/.project71
-rw-r--r--org.eclipse.scout.rt.testing.shared.test/META-INF/MANIFEST.MF11
-rw-r--r--org.eclipse.scout.rt.testing.shared.test/about.html28
-rw-r--r--org.eclipse.scout.rt.testing.shared.test/build.properties12
-rw-r--r--org.eclipse.scout.rt.testing.shared.test/pom.xml23
-rw-r--r--org.eclipse.scout.rt.testing.shared.test/src/org/eclipse/scout/rt/testing/shared/JUnitTestClassBrowserTest.java122
14 files changed, 821 insertions, 35 deletions
diff --git a/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/basic/table/columns/ColumnAutoResizeTest.java b/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/basic/table/columns/ColumnAutoResizeTest.java
index 6e7ed8aecd..5168723006 100644
--- a/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/basic/table/columns/ColumnAutoResizeTest.java
+++ b/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/basic/table/columns/ColumnAutoResizeTest.java
@@ -118,7 +118,4 @@ public class ColumnAutoResizeTest {
public static class PageWithNode extends AbstractPageWithNodes {
}
-
- public static class P_Desktop extends AbstractDesktop {
- }
}
diff --git a/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/shared/data/form/ImportFormDataWithTemplatesTest.java b/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/shared/data/form/FormDataImportWithTemplatesTest.java
index 85b233f6eb..e81d14f433 100644
--- a/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/shared/data/form/ImportFormDataWithTemplatesTest.java
+++ b/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/shared/data/form/FormDataImportWithTemplatesTest.java
@@ -19,7 +19,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(ScoutClientTestRunner.class)
-public class ImportFormDataWithTemplatesTest {
+public class FormDataImportWithTemplatesTest {
@Test
public void testExportImport() throws ProcessingException {
diff --git a/org.eclipse.scout.rt.parent/pom.xml b/org.eclipse.scout.rt.parent/pom.xml
index be6ead06ad..afd126193a 100644
--- a/org.eclipse.scout.rt.parent/pom.xml
+++ b/org.eclipse.scout.rt.parent/pom.xml
@@ -107,6 +107,7 @@
<module>../org.eclipse.scout.rt.testing.server</module>
<module>../org.eclipse.scout.rt.testing.server.test</module>
<module>../org.eclipse.scout.rt.testing.shared</module>
+ <module>../org.eclipse.scout.rt.testing.shared.test</module>
<module>../org.eclipse.scout.rt.testing.ui.rap</module>
<module>../org.eclipse.scout.rt.testing.ui.swing</module>
<module>../org.eclipse.scout.rt.testing.ui.swt</module>
diff --git a/org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/CodeLookupCallTest.java b/org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/CodeLookupCallTest.java
new file mode 100644
index 0000000000..d84fc28cdd
--- /dev/null
+++ b/org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/CodeLookupCallTest.java
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ * Copyright (c) 2013 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.shared.services.lookup;
+
+import java.util.List;
+
+import org.eclipse.scout.commons.CompareUtility;
+import org.eclipse.scout.commons.exception.ProcessingException;
+import org.eclipse.scout.rt.shared.Activator;
+import org.eclipse.scout.rt.shared.data.basic.FontSpec;
+import org.eclipse.scout.rt.shared.services.common.code.AbstractCodeType;
+import org.eclipse.scout.rt.shared.services.common.code.CodeRow;
+import org.eclipse.scout.rt.shared.services.common.code.ICode;
+import org.eclipse.scout.rt.shared.services.lookup.fixture.ILegacyCodeLookupCallVisitor;
+import org.eclipse.scout.rt.shared.services.lookup.fixture.LegacyCodeLookupCall;
+import org.eclipse.scout.rt.testing.shared.TestingUtility;
+import org.eclipse.scout.rt.testing.shared.services.common.code.TestingCodeService;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * JUnit test for {@link CodeLookupCall}.
+ * Test that the implementation of Bug 364312 does not affect the lookup call's behaviour (no side effects).
+ */
+public class CodeLookupCallTest {
+ private static final Integer ROW10_KEY = Integer.valueOf(10);
+ private static final String ROW10_TEXT = "lorem";
+ private static final Integer ROW11_KEY = Integer.valueOf(21);
+ private static final String ROW11_TEXT = "for";
+ private static final Integer ROW12_KEY = Integer.valueOf(22);
+ private static final String ROW12_TEXT = "ipi";
+ private static final Integer ROW20_KEY = Integer.valueOf(12);
+ private static final String ROW20_TEXT = "ipsum";
+ private static final Integer ROW30_KEY = Integer.valueOf(13);
+ private static final String ROW30_TEXT = "dolor";
+ private static final Integer ROW31_KEY = Integer.valueOf(43);
+ private static final String ROW31_TEXT = "mor";
+
+ private static List<ServiceRegistration> s_services;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ s_services = TestingUtility.registerServices(Activator.getDefault().getBundle(), 1000, new TestingCodeService(new CodeLookupCallTestCodeType()));
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ TestingUtility.unregisterServices(s_services);
+ }
+
+ @Test
+ public void testGetDataByAll() throws Exception {
+ P_LegacyCodeLookupCall oldLc = new P_LegacyCodeLookupCall();
+ LookupRow[] oldRows = oldLc.getDataByAll();
+
+ P_NewCodeLookupCall newLc = new P_NewCodeLookupCall();
+ LookupRow[] newRows = newLc.getDataByAll();
+
+ Assert.assertTrue("identical rows for old and new lookup call", equals(oldRows, newRows));
+ }
+
+ @Test
+ public void testGetDataByText() throws Exception {
+ P_LegacyCodeLookupCall oldLc = new P_LegacyCodeLookupCall();
+ LookupRow[] oldRows = oldLc.getDataByText();
+
+ P_NewCodeLookupCall newLc = new P_NewCodeLookupCall();
+ LookupRow[] newRows = newLc.getDataByText();
+
+ Assert.assertTrue("identical rows for old and new lookup call", equals(oldRows, newRows));
+ }
+
+ @Test
+ public void testGetDataByTextFiltered() throws Exception {
+ runGetDataByTextFiltered(null);
+ runGetDataByTextFiltered("*or*");
+ runGetDataByTextFiltered("*or");
+ runGetDataByTextFiltered("ip");
+ runGetDataByTextFiltered("foo");
+ runGetDataByTextFiltered("ipi");
+ runGetDataByTextFiltered("*");
+ runGetDataByTextFiltered("");
+ }
+
+ private void runGetDataByTextFiltered(String text) throws ProcessingException {
+
+ P_LegacyCodeLookupCall oldLc = new P_LegacyCodeLookupCall();
+ oldLc.setText(text);
+ LookupRow[] oldRows = oldLc.getDataByText();
+
+ P_NewCodeLookupCall newLc = new P_NewCodeLookupCall();
+ newLc.setText(text);
+ LookupRow[] newRows = newLc.getDataByText();
+
+ Assert.assertTrue("identical rows for old and new lookup call", equals(oldRows, newRows));
+ }
+
+ @Test
+ public void testGetDataByKey() throws Exception {
+ runGetDataByKey(0, null);
+ runGetDataByKey(1, ROW10_KEY);
+ runGetDataByKey(1, ROW31_KEY);
+ runGetDataByKey(0, "x");
+ runGetDataByKey(0, Integer.valueOf(0));
+ }
+
+ private void runGetDataByKey(int expectedLength, Object key) throws ProcessingException {
+
+ P_LegacyCodeLookupCall oldLc = new P_LegacyCodeLookupCall();
+ oldLc.setKey(key);
+ LookupRow[] oldRows = oldLc.getDataByKey();
+
+ P_NewCodeLookupCall newLc = new P_NewCodeLookupCall();
+ newLc.setKey(key);
+ LookupRow[] newRows = newLc.getDataByKey();
+
+ Assert.assertTrue("identical rows for old and new lookup call", equals(oldRows, newRows));
+ }
+
+ @Test
+ public void testGetDataByRec() throws Exception {
+ runGetDataByRec(3, null);
+ runGetDataByRec(2, ROW10_KEY);
+ runGetDataByRec(0, ROW20_KEY);
+ runGetDataByRec(1, ROW30_KEY);
+ runGetDataByRec(0, ROW11_KEY);
+ runGetDataByRec(0, "x");
+
+ }
+
+ private void runGetDataByRec(int expectedLength, Object parent) throws ProcessingException {
+ P_LegacyCodeLookupCall oldLc = new P_LegacyCodeLookupCall();
+ oldLc.setRec(parent);
+ LookupRow[] oldRows = oldLc.getDataByRec();
+
+ P_NewCodeLookupCall newLc = new P_NewCodeLookupCall();
+ newLc.setRec(parent);
+ LookupRow[] newRows = newLc.getDataByRec();
+
+ Assert.assertTrue("identical rows for old and new lookup call", equals(oldRows, newRows));
+ }
+
+ @Test
+ public void testGetFilteredData() throws Exception {
+
+ P_LegacyCodeLookupCall oldLc = new P_LegacyCodeLookupCall();
+ oldLc.setFilter(new ILegacyCodeLookupCallVisitor() {
+ @Override
+ public boolean visit(LegacyCodeLookupCall call, ICode code, int treeLevel) {
+ return true;
+ }
+ });
+ LookupRow[] oldRows = oldLc.getDataByAll();
+
+ P_NewCodeLookupCall newLc = new P_NewCodeLookupCall();
+ newLc.setFilter(new ICodeLookupCallVisitor() {
+
+ @Override
+ public boolean visit(CodeLookupCall call, ICode code, int treeLevel) {
+ return true;
+ }
+ });
+ LookupRow[] newRows = newLc.getDataByAll();
+
+ Assert.assertTrue("identical rows for old and new lookup call", equals(oldRows, newRows));
+ }
+
+ private static boolean equals(LookupRow[] rows1, LookupRow[] rows2) {
+ if ((rows1 == null && rows2 != null) || (rows1 != null && rows2 == null)) {
+ return false;
+ }
+
+ if (rows1 != null) {
+ if (rows1.length != rows2.length) {
+ return false;
+ }
+ for (int i = 0; i < rows1.length; i++) {
+ if (!equals(rows1[i], rows2[i])) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private static boolean equals(LookupRow row1, LookupRow row2) {
+ return CompareUtility.equals(row1.getBackgroundColor(), row2.getBackgroundColor()) && CompareUtility.equals(row1.getFont(), row2.getFont()) && CompareUtility.equals(row1.getForegroundColor(), row2.getForegroundColor()) && CompareUtility.equals(row1.getIconId(), row2.getIconId()) && CompareUtility.equals(row1.getKey(), row2.getKey()) && CompareUtility.equals(row1.getParentKey(), row2.getParentKey()) && CompareUtility.equals(row1.getText(), row2.getText()) && CompareUtility.equals(row1.getTooltipText(), row2.getTooltipText());
+ }
+
+ private class P_NewCodeLookupCall extends CodeLookupCall {
+ public P_NewCodeLookupCall() {
+ super(CodeLookupCallTestCodeType.class);
+ }
+
+ private static final long serialVersionUID = 1L;
+ }
+
+ private class P_LegacyCodeLookupCall extends LegacyCodeLookupCall {
+ public P_LegacyCodeLookupCall() {
+ super(CodeLookupCallTestCodeType.class);
+ }
+
+ private static final long serialVersionUID = 1L;
+ }
+
+ private static class CodeLookupCallTestCodeType extends AbstractCodeType<String> {
+ private static final long serialVersionUID = 1L;
+ public static final String ID = "CodeLookupCallTestCodeId";
+
+ public static final String ICON = "configuredIcon";
+ public static final String TOOLTIP = "configuredTooltip";
+ public static final String BACKGROUND_COLOR = "configuredBackgroundColor";
+ public static final String FOREGROUND_COLOR = "configuredForegroundColor";
+ public static final String FONT = "null-ITALIC-0";
+ public static final boolean ENABLED = false;
+ public static final boolean ACTIVE = false;
+ public static final String EXT_KEY = "configuredExtKey";
+ public static final double VALUE = 42d;
+
+ @Override
+ public String getId() {
+ return ID;
+ }
+
+ @Override
+ protected CodeRow[] execLoadCodes() throws ProcessingException {
+ CodeRow[] result = new CodeRow[]{
+ createTestCodeRow(ROW10_KEY, null, ROW10_TEXT),
+ createTestCodeRow(ROW11_KEY, ROW10_KEY, ROW11_TEXT),
+ createTestCodeRow(ROW12_KEY, ROW10_KEY, ROW12_TEXT),
+ createTestCodeRow(ROW20_KEY, null, ROW20_TEXT),
+ createTestCodeRow(ROW30_KEY, null, ROW30_TEXT),
+ createTestCodeRow(ROW31_KEY, ROW30_KEY, ROW31_TEXT)
+ };
+ return result;
+ }
+ }
+
+ private static CodeRow createTestCodeRow(Integer key, Integer parentKey, String text) {
+ return new CodeRow(key,
+ text,
+ CodeLookupCallTestCodeType.ICON,
+ CodeLookupCallTestCodeType.TOOLTIP,
+ CodeLookupCallTestCodeType.BACKGROUND_COLOR,
+ CodeLookupCallTestCodeType.FOREGROUND_COLOR,
+ FontSpec.parse(CodeLookupCallTestCodeType.FONT),
+ CodeLookupCallTestCodeType.ENABLED,
+ parentKey,
+ CodeLookupCallTestCodeType.ACTIVE,
+ CodeLookupCallTestCodeType.EXT_KEY,
+ CodeLookupCallTestCodeType.VALUE,
+ 0);
+ }
+}
diff --git a/org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/fixture/ILegacyCodeLookupCallVisitor.java b/org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/fixture/ILegacyCodeLookupCallVisitor.java
new file mode 100644
index 0000000000..c71562da4f
--- /dev/null
+++ b/org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/fixture/ILegacyCodeLookupCallVisitor.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2013 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.shared.services.lookup.fixture;
+
+import org.eclipse.scout.rt.shared.services.common.code.ICode;
+
+public interface ILegacyCodeLookupCallVisitor {
+
+ /**
+ * @return true=continue visiting, false=end visiting
+ */
+ boolean visit(LegacyCodeLookupCall call, ICode code, int treeLevel);
+
+}
diff --git a/org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/fixture/LegacyCodeLookupCall.java b/org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/fixture/LegacyCodeLookupCall.java
new file mode 100644
index 0000000000..c57f54b3ff
--- /dev/null
+++ b/org.eclipse.scout.rt.shared.test/src/org/eclipse/scout/rt/shared/services/lookup/fixture/LegacyCodeLookupCall.java
@@ -0,0 +1,243 @@
+/*******************************************************************************
+ * Copyright (c) 2013 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.shared.services.lookup.fixture;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.eclipse.scout.commons.StringUtility;
+import org.eclipse.scout.commons.exception.ProcessingException;
+import org.eclipse.scout.rt.shared.services.common.code.CODES;
+import org.eclipse.scout.rt.shared.services.common.code.ICode;
+import org.eclipse.scout.rt.shared.services.common.code.ICodeType;
+import org.eclipse.scout.rt.shared.services.common.code.ICodeVisitor;
+import org.eclipse.scout.rt.shared.services.lookup.CodeLookupCallTest;
+import org.eclipse.scout.rt.shared.services.lookup.LocalLookupCall;
+import org.eclipse.scout.rt.shared.services.lookup.LookupRow;
+
+/**
+ * This is an old version of the {@code CodeLookupCall} class required only for unit tests.
+ *
+ * @see CodeLookupCallTest
+ */
+public class LegacyCodeLookupCall extends LocalLookupCall implements Serializable {
+ private static final long serialVersionUID = 0L;
+
+ private Class<? extends ICodeType> m_codeTypeClass;
+ private ILegacyCodeLookupCallVisitor m_filter;
+
+ public LegacyCodeLookupCall(Class<? extends ICodeType> codeTypeClass) {
+ m_codeTypeClass = codeTypeClass;
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!super.equals(obj)) {
+ return false;
+ }
+ LegacyCodeLookupCall other = (LegacyCodeLookupCall) obj;
+ if (this.m_codeTypeClass != other.m_codeTypeClass) {
+ return false;
+ }
+ if (this.m_filter != other.m_filter) {
+ return false;
+ }
+ return true;
+ }
+
+ public Class<? extends ICodeType> getCodeTypeClass() {
+ return m_codeTypeClass;
+ }
+
+ public void setFilter(ILegacyCodeLookupCallVisitor filter) {
+ m_filter = filter;
+ }
+
+ public ILegacyCodeLookupCallVisitor getFilter() {
+ return m_filter;
+ }
+
+ /**
+ * Implementation that creates lookup rows from codes.
+ * <p>
+ * By default calls {@link #createLookupRowArray(List)}
+ */
+ protected LookupRow[] execCreateLookupRowsFromCodes(List<? extends ICode<?>> codes) {
+ return createLookupRowArray(codes);
+ }
+
+ /**
+ * Default implementation to create lookup rows from codes.
+ * <p>
+ * Called by {@link #execCreateLookupRowsFromCodes(List)}.
+ */
+ public static LookupRow[] createLookupRowArray(List<? extends ICode> codes) {
+ LookupRow[] a = new LookupRow[codes.size()];
+ for (int i = 0; i < a.length; i++) {
+ ICode c = codes.get(i);
+ Object parentId = null;
+ if (c.getParentCode() != null) {
+ parentId = c.getParentCode().getId();
+ }
+ a[i] = new LookupRow(c.getId(), c.getText(), c.getIconId(), c.getTooltipText(), c.getBackgroundColor(), c.getForegroundColor(), c.getFont(), c.isEnabled(), parentId, c.isActive());
+ }
+ return a;
+ }
+
+ public static Pattern getSearchPattern(String s) {
+ if (s == null) {
+ s = "";
+ }
+ s = s.toLowerCase();
+ if (!s.endsWith("*")) {
+ s = s + "*";
+ }
+ return Pattern.compile(StringUtility.toRegExPattern(s), Pattern.DOTALL);
+ }
+
+ /**
+ * Complete override using code data
+ */
+ @Override
+ public LookupRow[] getDataByKey() throws ProcessingException {
+ Object key = getKey();
+ ArrayList<ICode<?>> list = new ArrayList<ICode<?>>(1);
+ ICodeType t = CODES.getCodeType(m_codeTypeClass);
+ if (t != null) {
+ ICode c = t.getCode(key);
+ if (c != null) {
+ list.add(c);
+ }
+ }
+ return execCreateLookupRowsFromCodes(list);
+ }
+
+ /**
+ * Complete override using code data
+ */
+ @Override
+ public LookupRow[] getDataByText() throws ProcessingException {
+ final Pattern pat = getSearchPattern(getText());
+ P_AbstractCollectingCodeVisitor v = new P_AbstractCollectingCodeVisitor() {
+ @Override
+ public boolean visit(ICode code, int treeLevel) {
+ if (m_filter != null && !m_filter.visit(LegacyCodeLookupCall.this, code, treeLevel)) {
+ return true;
+ }
+ if (getActive().isUndefined() || getActive().getBooleanValue() == code.isActive()) {
+ if (code.getText() != null) {
+ if (pat.matcher(code.getText().toLowerCase()).matches()) {
+ add(code);
+ }
+ }
+ }
+ return true;
+ }
+ };
+ ICodeType t = CODES.getCodeType(m_codeTypeClass);
+ if (t != null) {
+ t.visit(v, false);
+ }
+ return execCreateLookupRowsFromCodes(v.getCodes());
+ }
+
+ /**
+ * Complete override using code data
+ */
+ @Override
+ public LookupRow[] getDataByAll() throws ProcessingException {
+ final Pattern pat = getSearchPattern(getAll());
+ P_AbstractCollectingCodeVisitor v = new P_AbstractCollectingCodeVisitor() {
+ @Override
+ public boolean visit(ICode code, int treeLevel) {
+ if (m_filter != null && !m_filter.visit(LegacyCodeLookupCall.this, code, treeLevel)) {
+ return true;
+ }
+ if (getActive().isUndefined() || getActive().getBooleanValue() == code.isActive()) {
+ if (code.getText() != null) {
+ if (pat.matcher(code.getText().toLowerCase()).matches()) {
+ add(code);
+ }
+ }
+ }
+ return true;
+ }
+ };
+ ICodeType t = CODES.getCodeType(m_codeTypeClass);
+ if (t != null) {
+ t.visit(v, false);
+ }
+ return execCreateLookupRowsFromCodes(v.getCodes());
+ }
+
+ /**
+ * Complete override using code data
+ */
+ @Override
+ public LookupRow[] getDataByRec() throws ProcessingException {
+ Object recValue = getRec();
+ if ((recValue instanceof Number) && ((Number) recValue).longValue() == 0) {
+ recValue = null;
+ }
+ final Object key = recValue;
+ P_AbstractCollectingCodeVisitor v = new P_AbstractCollectingCodeVisitor() {
+ @Override
+ public boolean visit(ICode code, int treeLevel) {
+ if (m_filter != null && !m_filter.visit(LegacyCodeLookupCall.this, code, treeLevel)) {
+ return true;
+ }
+ ICode parentCode = code.getParentCode();
+ if (getActive().isUndefined() || getActive().getBooleanValue() == code.isActive()) {
+ if (((parentCode == null && key == null) || (parentCode != null && parentCode.getId() != null && parentCode.getId().equals(key)))) {
+ add(code);
+ }
+ }
+ return true;
+ }
+ };
+ ICodeType t = CODES.getCodeType(m_codeTypeClass);
+ if (t != null) {
+ t.visit(v, false);
+ }
+ return execCreateLookupRowsFromCodes(v.getCodes());
+ }
+
+ private static abstract class P_AbstractCollectingCodeVisitor implements ICodeVisitor {
+ private ArrayList<ICode<?>> m_list = new ArrayList<ICode<?>>();
+
+ public P_AbstractCollectingCodeVisitor() {
+ }
+
+ public void add(ICode code) {
+ m_list.add(code);
+ }
+
+ public ICode getFirstCode() {
+ if (m_list.size() > 0) {
+ return m_list.get(0);
+ }
+ else {
+ return null;
+ }
+ }
+
+ public List<ICode<?>> getCodes() {
+ return m_list;
+ }
+ }
+}
diff --git a/org.eclipse.scout.rt.testing.server.test/src/org/eclipse/scout/rt/testing/server/runner/ScoutServerTestRunnerTransactionBehaviorTest.java b/org.eclipse.scout.rt.testing.server.test/src/org/eclipse/scout/rt/testing/server/runner/ScoutServerTestRunnerTransactionBehaviorTest.java
index 676d2c7ca8..6f12e0c1d8 100644
--- a/org.eclipse.scout.rt.testing.server.test/src/org/eclipse/scout/rt/testing/server/runner/ScoutServerTestRunnerTransactionBehaviorTest.java
+++ b/org.eclipse.scout.rt.testing.server.test/src/org/eclipse/scout/rt/testing/server/runner/ScoutServerTestRunnerTransactionBehaviorTest.java
@@ -37,8 +37,7 @@ public class ScoutServerTestRunnerTransactionBehaviorTest {
private static ITransaction s_beforeClassTransaction;
private static ITransaction s_afterClassTransaction;
- // before and after test transactions. The content is switched in method
- // checkTestTransactionBehavior.
+ // before and after test transactions. The content is switched in method checkTestTransactionBehavior.
private static ITransaction s_thisTestBeforeTransaction;
private static ITransaction s_thisTestAfterTransaction;
@@ -96,59 +95,46 @@ public class ScoutServerTestRunnerTransactionBehaviorTest {
}
/**
- * All methods annotated with @BeforeClass are expected to be executed in
- * the same Scout transaction.
+ * All methods annotated with @BeforeClass are expected to be executed in the same Scout transaction.
*/
private static void checkBeforeClassTransactionBehavior() {
Assert.assertNotNull(TestEnvironmentServerSession.get());
Assert.assertNotNull(ThreadContext.getTransaction());
- Assert.assertTrue(s_beforeClassTransaction == null
- || s_beforeClassTransaction == ThreadContext.getTransaction());
+ Assert.assertTrue(s_beforeClassTransaction == null || s_beforeClassTransaction == ThreadContext.getTransaction());
s_beforeClassTransaction = ThreadContext.getTransaction();
}
/**
- * All methods annotated with @BeforeClass are expected to be executed in
- * the same Scout transaction.
+ * All methods annotated with @BeforeClass are expected to be executed in the same Scout transaction.
*/
private static void checkAfterClassTransactionBehavior() {
Assert.assertNotNull(TestEnvironmentServerSession.get());
Assert.assertNotNull(ThreadContext.getTransaction());
- Assert.assertNotSame(s_beforeClassTransaction,
- ThreadContext.getTransaction());
- Assert.assertTrue(s_afterClassTransaction == null
- || s_afterClassTransaction == ThreadContext.getTransaction());
+ Assert.assertNotSame(s_beforeClassTransaction, ThreadContext.getTransaction());
+ Assert.assertTrue(s_afterClassTransaction == null || s_afterClassTransaction == ThreadContext.getTransaction());
s_afterClassTransaction = ThreadContext.getTransaction();
}
/**
- * All methods annotated with @Before are expected to be executed in the
- * same Scout transaction.
+ * All methods annotated with @Before are expected to be executed in the same Scout transaction.
*/
private static void checkBeforeTransactionBehavior() {
Assert.assertNotNull(TestEnvironmentServerSession.get());
Assert.assertNotNull(ThreadContext.getTransaction());
- Assert.assertNotSame(s_beforeClassTransaction,
- ThreadContext.getTransaction());
- Assert.assertTrue(s_thisTestBeforeTransaction == null
- || s_thisTestBeforeTransaction == ThreadContext
- .getTransaction());
- Assert.assertTrue(s_otherTestTransaction == null
- || s_otherTestTransaction != ThreadContext.getTransaction());
+ Assert.assertNotSame(s_beforeClassTransaction, ThreadContext.getTransaction());
+ Assert.assertTrue(s_thisTestBeforeTransaction == null || s_thisTestBeforeTransaction == ThreadContext.getTransaction());
+ Assert.assertTrue(s_otherTestTransaction == null || s_otherTestTransaction != ThreadContext.getTransaction());
s_thisTestBeforeTransaction = ThreadContext.getTransaction();
}
/**
- * All methods annotated with @After are expected to be executed in the same
- * Scout transaction.
+ * All methods annotated with @After are expected to be executed in the same Scout transaction.
*/
private static void checkAfterTransactionBehavior() {
Assert.assertNotNull(TestEnvironmentServerSession.get());
Assert.assertNotNull(ThreadContext.getTransaction());
- Assert.assertNotSame(s_beforeClassTransaction,
- ThreadContext.getTransaction());
- Assert.assertSame(s_thisTestAfterTransaction,
- ThreadContext.getTransaction());
+ Assert.assertNotSame(s_beforeClassTransaction, ThreadContext.getTransaction());
+ Assert.assertSame(s_thisTestAfterTransaction, ThreadContext.getTransaction());
}
/**
@@ -157,10 +143,8 @@ public class ScoutServerTestRunnerTransactionBehaviorTest {
private void checkTestTransactionBehavior() {
Assert.assertNotNull(TestEnvironmentServerSession.get());
Assert.assertNotNull(ThreadContext.getTransaction());
- Assert.assertNotSame(s_beforeClassTransaction,
- ThreadContext.getTransaction());
- Assert.assertTrue(s_otherTestTransaction == null
- || s_otherTestTransaction != ThreadContext.getTransaction());
+ Assert.assertNotSame(s_beforeClassTransaction, ThreadContext.getTransaction());
+ Assert.assertTrue(s_otherTestTransaction == null || s_otherTestTransaction != ThreadContext.getTransaction());
s_otherTestTransaction = ThreadContext.getTransaction();
s_thisTestAfterTransaction = s_thisTestBeforeTransaction;
s_thisTestBeforeTransaction = null;
diff --git a/org.eclipse.scout.rt.testing.shared.test/.classpath b/org.eclipse.scout.rt.testing.shared.test/.classpath
new file mode 100644
index 0000000000..0b1bcf949f
--- /dev/null
+++ b/org.eclipse.scout.rt.testing.shared.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.scout.rt.testing.shared.test/.project b/org.eclipse.scout.rt.testing.shared.test/.project
new file mode 100644
index 0000000000..89414c5e20
--- /dev/null
+++ b/org.eclipse.scout.rt.testing.shared.test/.project
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.scout.rt.testing.shared.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+ <linkedResources>
+ <link>
+ <name>.settings/de.loskutov.anyedit.AnyEditTools.prefs</name>
+ <type>1</type>
+ <locationURI>PARENT-1-PROJECT_LOC/org.eclipse.scout.rt-feature/.settings/de.loskutov.anyedit.AnyEditTools.prefs</locationURI>
+ </link>
+ <link>
+ <name>.settings/org.eclipse.core.resources.prefs</name>
+ <type>1</type>
+ <locationURI>PARENT-1-PROJECT_LOC/org.eclipse.scout.rt-feature/.settings/org.eclipse.core.resources.prefs</locationURI>
+ </link>
+ <link>
+ <name>.settings/org.eclipse.core.runtime.prefs</name>
+ <type>1</type>
+ <locationURI>PARENT-1-PROJECT_LOC/org.eclipse.scout.rt-feature/.settings/org.eclipse.core.runtime.prefs</locationURI>
+ </link>
+ <link>
+ <name>.settings/org.eclipse.jdt.core.prefs</name>
+ <type>1</type>
+ <locationURI>PARENT-1-PROJECT_LOC/org.eclipse.scout.rt-feature/.settings/org.eclipse.jdt.core.prefs</locationURI>
+ </link>
+ <link>
+ <name>.settings/org.eclipse.jdt.ui.prefs</name>
+ <type>1</type>
+ <locationURI>PARENT-1-PROJECT_LOC/org.eclipse.scout.rt-feature/.settings/org.eclipse.jdt.ui.prefs</locationURI>
+ </link>
+ <link>
+ <name>.settings/org.eclipse.m2e.core.prefs</name>
+ <type>1</type>
+ <locationURI>PARENT-1-PROJECT_LOC/org.eclipse.scout.rt-feature/.settings/org.eclipse.m2e.core.prefs</locationURI>
+ </link>
+ <link>
+ <name>.settings/org.eclipse.pde.core.prefs</name>
+ <type>1</type>
+ <locationURI>PARENT-1-PROJECT_LOC/org.eclipse.scout.rt-feature/.settings/org.eclipse.pde.core.prefs</locationURI>
+ </link>
+ </linkedResources>
+</projectDescription>
diff --git a/org.eclipse.scout.rt.testing.shared.test/META-INF/MANIFEST.MF b/org.eclipse.scout.rt.testing.shared.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5da67cac1f
--- /dev/null
+++ b/org.eclipse.scout.rt.testing.shared.test/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Scout RT Testing Shared Test
+Bundle-SymbolicName: org.eclipse.scout.rt.testing.shared.test
+Bundle-Version: 3.9.0.qualifier
+Bundle-Vendor: Eclipse Scout Project
+Fragment-Host: org.eclipse.scout.rt.testing.shared;bundle-version="3.9.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.hamcrest.core;version="[1.3.0,2.0.0)",
+ org.junit;version="[4.9.0,5.0.0)",
+ org.junit.runner;version="[4.9.0,5.0.0)"
diff --git a/org.eclipse.scout.rt.testing.shared.test/about.html b/org.eclipse.scout.rt.testing.shared.test/about.html
new file mode 100644
index 0000000000..c258ef55d8
--- /dev/null
+++ b/org.eclipse.scout.rt.testing.shared.test/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/org.eclipse.scout.rt.testing.shared.test/build.properties b/org.eclipse.scout.rt.testing.shared.test/build.properties
new file mode 100644
index 0000000000..b0ac311e69
--- /dev/null
+++ b/org.eclipse.scout.rt.testing.shared.test/build.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2013 BSI Business Systems Integration AG.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+###############################################################################
+source.. = src/
+bin.includes = META-INF/,\
+ .,\
+ about.html
+src.includes = about.html
diff --git a/org.eclipse.scout.rt.testing.shared.test/pom.xml b/org.eclipse.scout.rt.testing.shared.test/pom.xml
new file mode 100644
index 0000000000..1663f27b66
--- /dev/null
+++ b/org.eclipse.scout.rt.testing.shared.test/pom.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2013 BSI Business Systems Integration AG.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.scout.rt</groupId>
+ <artifactId>org.eclipse.scout.rt.parent</artifactId>
+ <version>3.9.0-SNAPSHOT</version>
+ <relativePath>../org.eclipse.scout.rt.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.scout.rt.testing.shared.test</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+</project>
diff --git a/org.eclipse.scout.rt.testing.shared.test/src/org/eclipse/scout/rt/testing/shared/JUnitTestClassBrowserTest.java b/org.eclipse.scout.rt.testing.shared.test/src/org/eclipse/scout/rt/testing/shared/JUnitTestClassBrowserTest.java
new file mode 100644
index 0000000000..33d69a1aef
--- /dev/null
+++ b/org.eclipse.scout.rt.testing.shared.test/src/org/eclipse/scout/rt/testing/shared/JUnitTestClassBrowserTest.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2013 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.testing.shared;
+
+import java.util.regex.Pattern;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test for {@link JUnitTestClassBrowser}
+ */
+public class JUnitTestClassBrowserTest {
+
+ @Test
+ public void testToRegexPattern_nullAndEmpty() {
+ Assert.assertNull(JUnitTestClassBrowser.toRegexPattern(null));
+ Assert.assertEquals("", JUnitTestClassBrowser.toRegexPattern(""));
+ Assert.assertEquals("", JUnitTestClassBrowser.toRegexPattern(" "));
+ Assert.assertEquals("", JUnitTestClassBrowser.toRegexPattern(" \n \t "));
+ }
+
+ @Test
+ public void testToRegexPattern_wildcardPatterns() {
+ Assert.assertEquals("org", JUnitTestClassBrowser.toRegexPattern("org"));
+ Assert.assertEquals("org", JUnitTestClassBrowser.toRegexPattern("org "));
+ Assert.assertEquals("org", JUnitTestClassBrowser.toRegexPattern(" \t org \n"));
+ Assert.assertEquals("org\\.", JUnitTestClassBrowser.toRegexPattern("org."));
+ Assert.assertEquals("org\\..*", JUnitTestClassBrowser.toRegexPattern("org.*"));
+ Assert.assertEquals("org\\.eclipse\\..*", JUnitTestClassBrowser.toRegexPattern("org.eclipse.*"));
+ Assert.assertEquals("org\\.eclipse\\..*\\.testing\\..*", JUnitTestClassBrowser.toRegexPattern("org.eclipse.*.testing.*"));
+ Assert.assertEquals("org\\.eclipse\\..*\\.test.ng\\..*", JUnitTestClassBrowser.toRegexPattern("org.eclipse.*.test?ng.*"));
+ Assert.assertEquals("org\\.eclipse\\..*\\.test.ng..\\..*", JUnitTestClassBrowser.toRegexPattern("org.eclipse.*.test?ng??.*"));
+ }
+
+ @Test
+ public void testToRegexPattern_regexPatterns() {
+ Assert.assertEquals("org", JUnitTestClassBrowser.toRegexPattern("regex:org"));
+ Assert.assertEquals("org", JUnitTestClassBrowser.toRegexPattern("regex:org "));
+ Assert.assertEquals(" \t org", JUnitTestClassBrowser.toRegexPattern(" regex: \t org \n"));
+ Assert.assertEquals("org.", JUnitTestClassBrowser.toRegexPattern("regex:org."));
+ Assert.assertEquals("org.*", JUnitTestClassBrowser.toRegexPattern("regex:org.*"));
+ Assert.assertEquals("org.eclipse.*", JUnitTestClassBrowser.toRegexPattern("regex:org.eclipse.*"));
+ Assert.assertEquals("org.eclipse.*.testing.*", JUnitTestClassBrowser.toRegexPattern("regex:org.eclipse.*.testing.*"));
+ Assert.assertEquals(" org\\.[eclips]{7}\\..*\\.testing\\.*", JUnitTestClassBrowser.toRegexPattern("regex: org\\.[eclips]{7}\\..*\\.testing\\.*"));
+ }
+
+ @Test
+ public void testParseFilterPatterns_nullAndEmpty() {
+ Assert.assertNull(JUnitTestClassBrowser.parseFilterPatterns(null));
+ Assert.assertNull(JUnitTestClassBrowser.parseFilterPatterns(""));
+ Assert.assertNull(JUnitTestClassBrowser.parseFilterPatterns(" "));
+ Assert.assertNull(JUnitTestClassBrowser.parseFilterPatterns(" \n \t "));
+ Assert.assertNull(JUnitTestClassBrowser.parseFilterPatterns(" , "));
+ Assert.assertNull(JUnitTestClassBrowser.parseFilterPatterns("\n,\t"));
+ }
+
+ @Test
+ public void testParseFilterPatterns_wildcardPatterns() {
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\..*")}, JUnitTestClassBrowser.parseFilterPatterns("org.eclipse.*"));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\..*")}, JUnitTestClassBrowser.parseFilterPatterns(", org.eclipse.*"));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\..*")}, JUnitTestClassBrowser.parseFilterPatterns("org.eclipse.* , "));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\..*")}, JUnitTestClassBrowser.parseFilterPatterns("org.eclipse.*, , , "));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\.scout\\..*"), Pattern.compile("org\\.myproject\\..*")},
+ JUnitTestClassBrowser.parseFilterPatterns("org.eclipse.scout.*,org.myproject.*"));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\.scout\\..*"), Pattern.compile("org\\.myproject\\..*")},
+ JUnitTestClassBrowser.parseFilterPatterns("org.eclipse.scout.*, org.myproject.*"));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\.scout\\..*"), Pattern.compile("org\\.myproject\\..*")},
+ JUnitTestClassBrowser.parseFilterPatterns("org.eclipse.scout.*,org.myproject.* , "));
+ }
+
+ @Test
+ public void testParseFilterPatterns_regexPatterns() {
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\..*")}, JUnitTestClassBrowser.parseFilterPatterns("regex:org\\.eclipse\\..*"));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\..*")}, JUnitTestClassBrowser.parseFilterPatterns(", regex:org\\.eclipse\\..*"));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\..*")}, JUnitTestClassBrowser.parseFilterPatterns("regex:org\\.eclipse\\..* , "));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\..*")}, JUnitTestClassBrowser.parseFilterPatterns("regex:org\\.eclipse\\..*, , , "));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\.scout\\..*"), Pattern.compile("org\\.myproject\\..*")},
+ JUnitTestClassBrowser.parseFilterPatterns("regex:org\\.eclipse\\.scout\\..*,regex:org\\.myproject\\..*"));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\.scout\\..*"), Pattern.compile("org\\.myproject\\..*")},
+ JUnitTestClassBrowser.parseFilterPatterns("regex:org\\.eclipse\\.scout\\..*, regex:org\\.myproject\\..*"));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\.scout\\..*"), Pattern.compile("org\\.myproject\\..*")},
+ JUnitTestClassBrowser.parseFilterPatterns("regex:org\\.eclipse\\.scout\\..*,regex:org\\.myproject\\..* , "));
+ }
+
+ @Test
+ public void testParseFilterPatterns_mixedPatterns() {
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\.scout\\..*"), Pattern.compile("org\\.myproject\\..*")},
+ JUnitTestClassBrowser.parseFilterPatterns("org.eclipse.scout.*,regex:org\\.myproject\\..*"));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\.scout\\..*"), Pattern.compile("org\\.myproject\\..*")},
+ JUnitTestClassBrowser.parseFilterPatterns("org.eclipse.scout.*,regex:org\\.myproject\\..* "));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\.scout\\..*"), Pattern.compile("org\\.myproject\\..*")},
+ JUnitTestClassBrowser.parseFilterPatterns("org.eclipse.scout.*, regex:org\\.myproject\\..*"));
+ assertArrayEquals(new Pattern[]{Pattern.compile("org\\.eclipse\\.scout\\..*"), Pattern.compile("org\\.myproject\\..*")},
+ JUnitTestClassBrowser.parseFilterPatterns("regex:org\\.eclipse\\.scout\\..*,org.myproject.*"));
+ }
+
+ public static void assertArrayEquals(Pattern[] expected, Pattern[] actual) {
+ Assert.assertArrayEquals(toStrings(expected), toStrings(actual));
+ }
+
+ private static String[] toStrings(Pattern[] patterns) {
+ if (patterns == null) {
+ return null;
+ }
+ String[] strings = new String[patterns.length];
+ for (int i = 0; i < patterns.length; i++) {
+ if (patterns[i] != null) {
+ strings[i] = patterns[i].pattern();
+ }
+ }
+ return strings;
+ }
+}

Back to the top