[jbosstools-commits] JBoss Tools SVN: r44072 - in trunk/common/tests/org.jboss.tools.common.ui.test: META-INF and 5 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Sep 26 19:42:45 EDT 2012
Author: scabanovich
Date: 2012-09-26 19:42:45 -0400 (Wed, 26 Sep 2012)
New Revision: 44072
Added:
trunk/common/tests/org.jboss.tools.common.ui.test/projects/
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.classpath
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.project
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.settings/
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.settings/org.eclipse.jdt.core.prefs
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/bin/
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/src/
trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/src/test/
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/NewServiceProviderWizardTest.java
Modified:
trunk/common/tests/org.jboss.tools.common.ui.test/META-INF/MANIFEST.MF
trunk/common/tests/org.jboss.tools.common.ui.test/build.properties
trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/CommonUITestSuite.java
Log:
JBIDE-9443
https://issues.jboss.org/browse/JBIDE-9443
New Service Provider wizard. Test.
Modified: trunk/common/tests/org.jboss.tools.common.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/tests/org.jboss.tools.common.ui.test/META-INF/MANIFEST.MF 2012-09-26 23:36:13 UTC (rev 44071)
+++ trunk/common/tests/org.jboss.tools.common.ui.test/META-INF/MANIFEST.MF 2012-09-26 23:42:45 UTC (rev 44072)
@@ -8,7 +8,10 @@
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.jdt.core,
+ org.eclipse.ui.ide,
org.junit,
+ org.jboss.tools.common.core,
+ org.jboss.tools.common,
org.jboss.tools.common.ui,
org.jboss.tools.tests
Import-Package: org.jboss.tools.common.ui.preferencevalue
Modified: trunk/common/tests/org.jboss.tools.common.ui.test/build.properties
===================================================================
--- trunk/common/tests/org.jboss.tools.common.ui.test/build.properties 2012-09-26 23:36:13 UTC (rev 44071)
+++ trunk/common/tests/org.jboss.tools.common.ui.test/build.properties 2012-09-26 23:42:45 UTC (rev 44072)
@@ -1,5 +1,6 @@
source.. = src/
bin.includes = META-INF/,\
.,\
+ projects/,\
plugin.properties
src.includes = pom.xml
Added: trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.classpath
===================================================================
--- trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.classpath (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.classpath 2012-09-26 23:42:45 UTC (rev 44072)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.classpath
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.project
===================================================================
--- trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.project (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.project 2012-09-26 23:42:45 UTC (rev 44072)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.settings/org.eclipse.jdt.core.prefs 2012-09-26 23:42:45 UTC (rev 44072)
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Property changes on: trunk/common/tests/org.jboss.tools.common.ui.test/projects/Test/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
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-09-26 23:36:13 UTC (rev 44071)
+++ trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/CommonUITestSuite.java 2012-09-26 23:42:45 UTC (rev 44072)
@@ -18,7 +18,8 @@
@RunWith(Suite.class)
@Suite.SuiteClasses({
StringsPreferenceValueTest.class,
- JBossPerspectiveTest.class
+ JBossPerspectiveTest.class,
+ NewServiceProviderWizardTest.class
})
/**
* @author André Dietisheim
Added: 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 (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/NewServiceProviderWizardTest.java 2012-09-26 23:42:45 UTC (rev 44072)
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * 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 java.lang.reflect.Modifier;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
+import org.eclipse.jdt.ui.wizards.NewTypeWizardPage;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.ui.wizard.service.NewServiceCreationWizard;
+import org.jboss.tools.common.ui.wizard.service.NewServiceWizardPage;
+import org.jboss.tools.common.util.EclipseJavaUtil;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.test.util.JUnitUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+import org.jboss.tools.test.util.WorkbenchUtils;
+
+/**
+ * @author Viacheslav Kabanovich
+ *
+ */
+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";
+
+ static class WizardContext {
+ NewElementWizard wizard;
+ IProject tck;
+ IJavaProject jp;
+ WizardDialog dialog;
+ NewTypeWizardPage page;
+ String packName;
+ String typeName;
+
+
+ public void init(String wizardId, String packName, String typeName) {
+ this.packName = packName;
+ this.typeName = typeName;
+ wizard = (NewElementWizard)WorkbenchUtils.findWizardByDefId(wizardId);
+ tck = ResourcesPlugin.getWorkspace().getRoot().getProject("Test");
+ jp = EclipseUtil.getJavaProject(tck);
+ wizard.init(CommonUIPlugin.getDefault().getWorkbench(), new StructuredSelection(jp));
+ if(wizard instanceof NewServiceCreationWizard) {
+ ((NewServiceCreationWizard)wizard).setOpenEditorAfterFinish(false);
+ }
+ dialog = new WizardDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ wizard);
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+
+ page = (NewTypeWizardPage)dialog.getSelectedPage();
+
+ page.setTypeName(typeName, true);
+ IPackageFragment pack = page.getPackageFragmentRoot().getPackageFragment(PACK_NAME);
+ page.setPackageFragment(pack, true);
+ }
+
+ public String getNewTypeContent() {
+ IType type = null;
+ try {
+ String tn = typeName;
+ int q = tn.indexOf("<");
+ if(q >= 0) tn = tn.substring(0, q);
+ type = jp.findType(packName + "." + tn);
+ } catch (JavaModelException e) {
+ JUnitUtils.fail("Cannot find type " + typeName, e);
+ }
+
+ IFile file = (IFile)type.getResource();
+ assertNotNull(file);
+ String text = null;
+ try {
+ text = FileUtil.readStream(file.getContents());
+ } catch (CoreException e) {
+ JUnitUtils.fail("Cannot read from " + file, e);
+ }
+ return text;
+ }
+
+ public void close() {
+ dialog.close();
+ }
+
+ }
+
+ public void testNewServiceWizard() throws Exception {
+ WizardContext context = new WizardContext();
+ context.init("org.jboss.tools.common.ui.wizard.service.NewServiceCreationWizard",
+ PACK_NAME, SERVICE_NAME);
+
+ try {
+ NewServiceWizardPage page = (NewServiceWizardPage)context.page;
+
+ String serviceType = "java.util.List111";
+ page.setServiceType(serviceType);
+ String message = page.getErrorMessage();
+ String expectedMessage = NLS.bind(CommonUIMessages.NEW_SERVICE_WIZARD_SERVICE_TYPE_NOT_EXISTS, serviceType);
+ assertEquals(expectedMessage, message);
+
+ serviceType = "java.util.List";
+ page.setServiceType(serviceType);
+ assertNull(page.getErrorMessage());
+
+ context.wizard.performFinish();
+
+ String text = context.getNewTypeContent();
+
+ assertTrue(text.contains("@Override"));
+ assertTrue(text.contains("iterator()"));
+
+ IType type = (IType)context.wizard.getCreatedElement();
+ int f = type.getFlags();
+ assertTrue(Modifier.isPublic(f));
+ assertFalse(Modifier.isAbstract(f));
+ String[] is = type.getSuperInterfaceNames();
+ assertEquals(1, is.length);
+ assertEquals("List", is[0]);
+
+ IResource[] srcs = EclipseUtil.getJavaSourceRoots(type.getJavaProject().getProject());
+ IFile file = ((IFolder)srcs[0]).getFile(new Path("META-INF/services/java.util.List"));
+ assertTrue(file.exists());
+ String content = FileUtil.readStream(file);
+ assertEquals(type.getFullyQualifiedName(), content.trim());
+ } finally {
+ context.close();
+ }
+ }
+
+ public void setUp() {
+ try {
+ IProject p = ResourcesUtils.importProject("org.jboss.tools.common.ui.test", "projects/Test");
+ System.out.println(p);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/common/tests/org.jboss.tools.common.ui.test/src/org/jboss/tools/common/ui/NewServiceProviderWizardTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
More information about the jbosstools-commits
mailing list