Author: scabanovich
Date: 2012-10-05 19:55:34 -0400 (Fri, 05 Oct 2012)
New Revision: 44351
Added:
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/src/test/ListProvider.java
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/RegisterServiceProviderDialogTest.java
Modified:
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/CommonUITestSuite.java
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/NewServiceProviderWizardTest.java
Log:
JBIDE-12793
https://issues.jboss.org/browse/JBIDE-12793
Test is added.
Added:
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/src/test/ListProvider.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/src/test/ListProvider.java
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/src/test/ListProvider.java 2012-10-05
23:55:34 UTC (rev 44351)
@@ -0,0 +1,7 @@
+package test;
+
+import java.util.ArrayList;
+
+public class ListProvider extends ArrayList<String> {
+
+}
\ No newline at end of file
Property changes on:
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/src/test/ListProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/CommonUITestSuite.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/CommonUITestSuite.java 2012-10-05
23:54:17 UTC (rev 44350)
+++
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/CommonUITestSuite.java 2012-10-05
23:55:34 UTC (rev 44351)
@@ -19,7 +19,8 @@
@Suite.SuiteClasses({
StringsPreferenceValueTest.class,
JBossPerspectiveTest.class,
- NewServiceProviderWizardTest.class
+ NewServiceProviderWizardTest.class,
+ RegisterServiceProviderDialogTest.class
})
/**
* @author André Dietisheim
Modified:
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/NewServiceProviderWizardTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/NewServiceProviderWizardTest.java 2012-10-05
23:54:17 UTC (rev 44350)
+++
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/NewServiceProviderWizardTest.java 2012-10-05
23:55:34 UTC (rev 44351)
@@ -20,6 +20,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
@@ -45,11 +46,12 @@
*
*/
public class NewServiceProviderWizardTest extends TestCase {
-
static String PACK_NAME = "test";
static String EXISTING_PACK_NAME =
"org.jboss.jsr299.tck.tests.jbt.validation.target";
static String EXISTING_INTERCEPTOR_BINDING_NAME =
"InterceptorBindingWTypeTarget"; // @Inherited @Target({TYPE})
static String SERVICE_NAME = "MyService";
+
+ IProject project;
static class WizardContext {
NewElementWizard wizard;
@@ -161,10 +163,17 @@
public void setUp() {
try {
- IProject p = ResourcesUtils.importProject("org.jboss.tools.common.ui.test",
"projects/Test");
- System.out.println(p);
+ project = ResourcesUtils.importProject("org.jboss.tools.common.ui.test",
"projects/Test");
} catch (Exception e) {
fail();
}
}
+
+ public void tearDown() {
+ try {
+ project.delete(true, new NullProgressMonitor());
+ } catch (Exception e) {
+ fail();
+ }
+ }
}
\ No newline at end of file
Added:
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/RegisterServiceProviderDialogTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/RegisterServiceProviderDialogTest.java
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/RegisterServiceProviderDialogTest.java 2012-10-05
23:55:34 UTC (rev 44351)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.ui;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.ui.wizard.service.RegisterAsServiceDialog;
+import org.jboss.tools.common.ui.wizard.service.RegisterServiceUtil;
+import org.jboss.tools.common.util.EclipseJavaUtil;
+import org.jboss.tools.test.util.ResourcesUtils;
+
+/**
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class RegisterServiceProviderDialogTest extends TestCase {
+ static String SERVICE_NAME = "test.ListProvider";
+ IProject project;
+
+ static class WizardContext {
+ IJavaProject jp;
+ RegisterAsServiceDialog dialog;
+ String typeName;
+ IType type;
+
+ public void init(String typeName) throws CoreException {
+ this.typeName = typeName;
+ IProject tck = ResourcesPlugin.getWorkspace().getRoot().getProject("Test");
+ jp = EclipseUtil.getJavaProject(tck);
+ type = EclipseJavaUtil.findType(jp, typeName);
+ dialog = new RegisterAsServiceDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), type);
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+ }
+
+ public void close() {
+ dialog.close();
+ }
+ }
+
+ public void testRegisterAsService() throws Exception {
+ WizardContext context = new WizardContext();
+ context.init(SERVICE_NAME);
+
+ try {
+ RegisterAsServiceDialog dialog = context.dialog;
+
+ dialog.setServiceType("java.util.ArrayList");
+ assertEquals(CommonUIMessages.REGISTER_AS_SERVICE_NON_ABSTRACT_MESSAGE,
dialog.getMessage());
+
+ dialog.setServiceType("java.util.List");
+ assertEquals(CommonUIMessages.REGISTER_AS_SERVICE_MESSAGE, dialog.getMessage());
+ dialog.okPressed();
+ String result = dialog.getResult();
+ try {
+ RegisterServiceUtil.registerService(context.type, result);
+ } catch (CoreException e) {
+ CommonUIPlugin.getDefault().logError(e);
+ }
+ assertEquals("java.util.List", result);
+
+ assertTrue(RegisterServiceUtil.isServiceRegistered(project, SERVICE_NAME,
result));
+
+ } finally {
+ context.close();
+ }
+
+ //2. Repeat and check same service type.
+ context = new WizardContext();
+ context.init(SERVICE_NAME);
+ try {
+ RegisterAsServiceDialog dialog = context.dialog;
+ dialog.setServiceType("java.util.List");
+ assertEquals(CommonUIMessages.REGISTER_AS_SERVICE_ALREADY_REGISTERED_MESSAGE,
dialog.getErrorMessage());
+
+ dialog.setServiceType("java.util.AbstractList");
+ assertNull(dialog.getErrorMessage());
+ assertEquals(CommonUIMessages.REGISTER_AS_SERVICE_MESSAGE, dialog.getMessage());
+ } finally {
+ context.close();
+ }
+ }
+
+ public void setUp() {
+ try {
+ project = ResourcesUtils.importProject("org.jboss.tools.common.ui.test",
"projects/Test");
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void tearDown() {
+ try {
+ project.delete(true, new NullProgressMonitor());
+ } catch (Exception e) {
+ fail();
+ }
+ }
+}
Property changes on:
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/RegisterServiceProviderDialogTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain