From 990e798fedde4c83e885f839af9dfff3d4cf1c28 Mon Sep 17 00:00:00 2001 From: Frank Becker Date: Wed, 20 Aug 2014 21:01:59 +0200 Subject: 442088: fix failing test for Luna (org.eclipse.core.runtime.compatibility.auth removed) Change-Id: Id0080523bf8c292ca7cf7d21db9921d1f97a8941 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=442088 --- org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF | 2 +- .../tasks/tests/TaskRepositoryCredentialsTest.java | 5 ++++ .../tasks/tests/TaskRepositoryManagerTest.java | 11 +++++++- .../eclipse/mylyn/tasks/tests/util/TestUtils.java | 29 ++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/util/TestUtils.java diff --git a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF index dca08d7c2..314dac87a 100644 --- a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF @@ -31,7 +31,7 @@ Require-Bundle: org.junit;bundle-version="4.8.2", org.eclipse.mylyn.tasks.ui, org.eclipse.mylyn.tests.util, org.eclipse.mylyn.commons.repositories.core, - org.eclipse.core.runtime.compatibility.auth + org.eclipse.core.runtime.compatibility.auth;resolution:=optional Export-Package: org.eclipse.mylyn.tasks.tests;x-internal:=true, org.eclipse.mylyn.tasks.tests.bugs;x-internal:=true, org.eclipse.mylyn.tasks.tests.connector;x-friends:="org.eclipse.mylyn.tasks.ui.tests", diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryCredentialsTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryCredentialsTest.java index 6ef2dedc9..8faab95de 100644 --- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryCredentialsTest.java +++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryCredentialsTest.java @@ -25,6 +25,7 @@ import org.eclipse.mylyn.commons.repositories.core.auth.ICredentialsStore; import org.eclipse.mylyn.internal.commons.repositories.core.LocationService; import org.eclipse.mylyn.internal.tasks.core.IRepositoryConstants; import org.eclipse.mylyn.tasks.core.TaskRepository; +import org.eclipse.mylyn.tasks.tests.util.TestUtils; /** * @author Mik Kersten @@ -78,6 +79,10 @@ public class TaskRepositoryCredentialsTest extends TestCase { @SuppressWarnings("deprecation") public void testPlatformAuthHandlerAvailable() throws Exception { + if (!TestUtils.isCompatibilityAuthInstalled()) { + System.err.println("Skipping TaskRepositoryCredentialsTest.testPlatformAuthHandlerAvailable()"); + return; + } URL url = new URL("http://mylyn"); Platform.addAuthorizationInfo(url, "", "", Collections.EMPTY_MAP); assertNotNull("Tests require org.eclipse.core.runtime.compatibility.auth", diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryManagerTest.java index 535ee15f5..fa3104665 100644 --- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryManagerTest.java +++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryManagerTest.java @@ -44,6 +44,7 @@ import org.eclipse.mylyn.tasks.core.TaskRepository; import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector; import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryQuery; import org.eclipse.mylyn.tasks.tests.connector.MockTask; +import org.eclipse.mylyn.tasks.tests.util.TestUtils; /** * @author Mik Kersten @@ -134,6 +135,10 @@ public class TaskRepositoryManagerTest extends TestCase { } public void testMigrationFromKeyring() throws Exception { + if (!TestUtils.isCompatibilityAuthInstalled()) { + System.err.println("Skipping TaskRepositoryManagerTest.testMigrationFromKeyring()"); + return; + } Map authInfo = createAuthInfo(); TaskRepository repository = new TaskRepository("bugzilla", "http://example.com/"); @@ -150,6 +155,10 @@ public class TaskRepositoryManagerTest extends TestCase { } public void testMigrationFromKeyringAfterGetUserNameCalled() throws Exception { + if (!TestUtils.isCompatibilityAuthInstalled()) { + System.err.println("Skipping TaskRepositoryManagerTest.testMigrationFromKeyringAfterGetUserNameCalled()"); + return; + } Map authInfo = createAuthInfo(); TaskRepository repository = new TaskRepository("bugzilla", "http://example.com/"); @@ -369,7 +378,7 @@ public class TaskRepositoryManagerTest extends TestCase { } public void testRepositoryWithCustomAttributes() throws Exception { - // Note: if a connector doesn't exist the associated repositories are not loaded (orphaned) + // Note: if a connector doesn't exist the associated repositories are not loaded (orphaned) // causing this test to fail. AbstractRepositoryConnector connector = new MockRepositoryConnector(); manager.addRepositoryConnector(connector); diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/util/TestUtils.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/util/TestUtils.java new file mode 100644 index 000000000..c9991a282 --- /dev/null +++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/util/TestUtils.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2014 Tasktop Technologies and others. + * 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: + * Tasktop Technologies - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.tasks.tests.util; + +import org.eclipse.core.runtime.Platform; + +public class TestUtils { + + private static class CompatibilityAuthChecker { + public static final boolean result; + static { + result = Platform.getBundle("org.eclipse.core.runtime.compatibility.auth") != null; //$NON-NLS-1$ + } + } + + public static boolean isCompatibilityAuthInstalled() { + return CompatibilityAuthChecker.result; + } + +} -- cgit v1.2.3