[255517] Remove Cactus
diff --git a/features/org.eclipse.jst.server_core.feature/feature.xml b/features/org.eclipse.jst.server_core.feature/feature.xml index 6b32474..bef6b12 100644 --- a/features/org.eclipse.jst.server_core.feature/feature.xml +++ b/features/org.eclipse.jst.server_core.feature/feature.xml
@@ -35,10 +35,4 @@ version="0.0.0" unpack="false"/> - <plugin - id="org.apache.cactus" - download-size="0" - install-size="0" - version="0.0.0"/> - </feature>
diff --git a/plugins/org.eclipse.jst.server.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.server.core/META-INF/MANIFEST.MF index 817c3d3..1e3f6a6 100644 --- a/plugins/org.eclipse.jst.server.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.jst.server.core/META-INF/MANIFEST.MF
@@ -2,13 +2,12 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jst.server.core; singleton:=true -Bundle-Version: 1.1.101.qualifier +Bundle-Version: 1.2.0.qualifier Bundle-Activator: org.eclipse.jst.server.core.internal.JavaServerPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.jst.server.core, - org.eclipse.jst.server.core.internal;x-friends:="org.eclipse.jst.server.ui", - org.eclipse.jst.server.core.internal.cactus;x-friends:="org.eclipse.jst.server.ui" + org.eclipse.jst.server.core.internal;x-friends:="org.eclipse.jst.server.ui" Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
diff --git a/plugins/org.eclipse.jst.server.core/plugin.xml b/plugins/org.eclipse.jst.server.core/plugin.xml index 17b1725..164304e 100644 --- a/plugins/org.eclipse.jst.server.core/plugin.xml +++ b/plugins/org.eclipse.jst.server.core/plugin.xml
@@ -55,37 +55,6 @@ class="org.eclipse.jst.server.core.internal.GenericRuntimeClasspathProvider"/> </extension> - <extension point="org.eclipse.core.expressions.propertyTesters"> - <propertyTester - namespace="org.eclipse.jst.cactus.expressions" - type="org.eclipse.core.runtime.IAdaptable" - class="org.eclipse.jst.server.core.internal.cactus.ServletTestCasePropertyTester" - properties="isServletTestCase" - id="org.eclipse.jst.server.cactus.expression"/> - </extension> - - <extension point="org.eclipse.wst.server.core.moduleArtifactAdapters"> - <moduleArtifactAdapter - id="org.eclipse.jst.server.cactus.moduleArtifactAdapter" - class="org.eclipse.jst.server.core.internal.cactus.CactusModuleArtifactAdapterDelegate" - priority="10"> - <enablement> - <or> - <instanceof value="org.eclipse.jdt.core.IMethod"/> - <instanceof value="org.eclipse.jdt.core.ICompilationUnit"/> - <instanceof value="org.eclipse.jdt.core.IType"/> - <instanceof value="org.eclipse.core.resources.IFile"/> - </or> - </enablement> - </moduleArtifactAdapter> - </extension> - - <extension point="org.eclipse.wst.server.core.launchableAdapters"> - <launchableAdapter - id="org.eclipse.jst.server.cactus.launchableAdapter" - class="org.eclipse.jst.server.core.internal.cactus.CactusLaunchableAdapterDelegate"/> - </extension> - <extension point="org.eclipse.wst.server.core.clients"> <client id="org.eclipse.jst.server.jndi"
diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.java index 0bfeeeb..472d5b6 100644 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.java +++ b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.java
@@ -38,7 +38,6 @@ public static String artifactServlet; public static String artifactEJB; public static String artifactJNDI; - public static String artifactCactusTest; public static String canModifyModules; public static String errorNoProfiler;
diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.properties b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.properties index 76c6ce4..dafe96b 100644 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.properties +++ b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/Messages.properties
@@ -34,11 +34,10 @@ artifactServlet=Servlet {0} artifactEJB=EJB {0} artifactJNDI=JNDI {0} -artifactCactusTest=Cactus test {0} canModifyModules=Web module can be added to the server. errorNoProfiler=Could not launch in profiling mode because no profilers are configured. -errorPublish=An error occured during publishing. +errorPublish=An error occurred during publishing. httpPort=HTTP Port errorPortInUse=Port {0} required by {1} is already in use. The server may already be running in another process, or a system process may be using the port. \ To start this server you will need to stop the other process or change the port number(s). \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchable.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchable.java deleted file mode 100644 index de2f447..0000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchable.java +++ /dev/null
@@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core.internal.cactus; - -import java.net.URL; -/** - * - */ -public class CactusLaunchable { - private String fProjectname; - private String fClassName; - private String fTestName; - private URL fCactusURL; - - public CactusLaunchable(String projectName, String className, String testName, URL cactusURL) { - fProjectname = projectName; - fClassName = className; - fTestName = testName; - fCactusURL = cactusURL; - } - - public String getTestClassName() { - return fClassName; - } - - public String getTestName() { - return fTestName; - } - - public String getProjectName() { - return fProjectname; - } - - public URL getCactusURL() { - return fCactusURL; - } -} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchableAdapterDelegate.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchableAdapterDelegate.java deleted file mode 100644 index 028f6fc..0000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusLaunchableAdapterDelegate.java +++ /dev/null
@@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core.internal.cactus; - -import java.net.MalformedURLException; -import java.net.URL; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jst.server.core.internal.Trace; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.model.IURLProvider; -import org.eclipse.wst.server.core.model.LaunchableAdapterDelegate; -/** - * - */ -public class CactusLaunchableAdapterDelegate extends LaunchableAdapterDelegate { - public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact) throws CoreException { - if (moduleArtifact instanceof WebTestableResource) { - WebTestableResource resource = (WebTestableResource) moduleArtifact; - URL url = ((IURLProvider) server.getAdapter(IURLProvider.class)) - .getModuleRootURL(resource.getModule()); - - String urlString = url.toString(); - if (urlString.endsWith("/")) { - try { - url = new URL(urlString.substring(0, urlString.length() - 1)); - } catch (MalformedURLException e) { - Trace.trace(Trace.SEVERE, "Error getting launchable", e); - return null; - } - } - return new CactusLaunchable(resource.getProjectName(), - resource.getClassName(), resource.getTestName(), url); - } - return null; - } -} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusModuleArtifactAdapterDelegate.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusModuleArtifactAdapterDelegate.java deleted file mode 100644 index 46a2819..0000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/CactusModuleArtifactAdapterDelegate.java +++ /dev/null
@@ -1,198 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core.internal.cactus; - -import java.util.Arrays; -import java.util.Iterator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.server.core.internal.Trace; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; -import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.model.ModuleArtifactAdapterDelegate; -/** - * - */ -public class CactusModuleArtifactAdapterDelegate extends ModuleArtifactAdapterDelegate { - private static final String SERVLET_TEST_CASE_TYPE = "org.apache.cactus.ServletTestCase"; - - private static final String SUITE_METHOD = "suite"; - - private static final String TEST_CLASS_NAME = "junit.framework.Test"; - - public IModuleArtifact getModuleArtifact(Object obj) { - String methodName = ""; - if (obj instanceof IMethod) { - IMethod method = (IMethod) obj; - methodName = method.getElementName(); - obj = method.getCompilationUnit(); - } - if (obj instanceof IAdaptable) { - IResource resource = (IResource) ((IAdaptable) obj).getAdapter(IResource.class); - String testClassName = getClassNameForType(resource); - if (testClassName != null) { - String projectName = resource.getProject().getName(); - return new WebTestableResource(getModule(resource.getProject()), false, - projectName, testClassName, methodName); - } - } - return null; - } - - private static String getClassNameForType(IResource resource) { - if (resource == null) - return null; - - if (!"java".equals(resource.getFileExtension()) && !"class".equals(resource.getFileExtension())) - return null; - - try { - IProject project = resource.getProject(); - IPath path = resource.getFullPath(); - if (path == null || !project.hasNature(JavaCore.NATURE_ID)) - return null; - - IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID); - if (!javaProject.isOpen()) - javaProject.open(new NullProgressMonitor()); - - // output location may not be on classpath - IPath outputPath = javaProject.getOutputLocation(); - if (outputPath != null - && "class".equals(path.getFileExtension()) && outputPath.isPrefixOf(path)) { //$NON-NLS-1$ - int count = outputPath.segmentCount(); - path = path.removeFirstSegments(count); - } - - // remove initial part of classpath - IClasspathEntry[] classPathEntry = javaProject.getResolvedClasspath(true); - if (classPathEntry != null) { - int size = classPathEntry.length; - for (int i = 0; i < size; i++) { - IPath classPath = classPathEntry[i].getPath(); - if (classPath.isPrefixOf(path)) { - int count = classPath.segmentCount(); - path = path.removeFirstSegments(count); - i += size; - } - } - } - - // get java element - IJavaElement javaElement = javaProject.findElement(path); - IType[] types = getTypes(javaElement); - if (types != null) { - int size2 = types.length; - for (int i = 0; i < size2; i++) { - if (hasSuperclass(types[i]) || hasSuiteMethod(types[i])) - return types[i].getFullyQualifiedName(); - } - } - return null; - } catch (Exception e) { - Trace.trace(Trace.WARNING, "Unexpected exception: " + e); - return null; - } - } - - private static boolean hasSuiteMethod(IType type) throws JavaModelException { - IMethod[] methods = type.getMethods(); - int size = methods.length; - for (int i = 0; i < size; i++) { - IMethod method = methods[i]; - if (method.getParameterNames().length == 0 && method.getElementName().equals(SUITE_METHOD)) { - String returnType = getFullyQualifiedTypeForMangledType(method.getReturnType(), type); - if (TEST_CLASS_NAME.equals(returnType)) - return true; - } - } - return false; - } - - private static IType[] getTypes(IJavaElement element) { - try { - if (element.getElementType() != IJavaElement.COMPILATION_UNIT) - return null; - return ((ICompilationUnit) element).getAllTypes(); - } catch (Exception e) { - return null; - } - } - - private static boolean hasSuperclass(IType type) { - try { - ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null); - IType[] superClasses = hierarchy.getAllSuperclasses(type); - int size = superClasses.length; - for (int i = 0; i < size; i++) { - if (SERVLET_TEST_CASE_TYPE.equals(superClasses[i].getFullyQualifiedName())) //$NON-NLS-1$ - return true; - } - return false; - } catch (Exception e) { - return false; - } - } - - protected static IModule getModule(IProject project) { - IModule deployable = null; - Iterator iterator = Arrays.asList(ServerUtil.getModules("jst.web")).iterator(); - while (iterator.hasNext()) { - Object next = iterator.next(); - if (next instanceof IModule) { - deployable = (IModule) next; - if (deployable.getProject().equals(project)) - return deployable; - } - } - return null; - } - - private static String getFullyQualifiedTypeForMangledType(String type, - IType declaringType) throws JavaModelException { - type = Signature.toString(type); - return getFullyQualifiedTypeForType(type, declaringType); - } - - private static String getFullyQualifiedTypeForType(String type, IType declaringType) - throws JavaModelException { - String[][] resolvedTypes = declaringType.resolveType(type); - // Are there legit cases where this would not be the case? We might need to check - // for this and bomb out if the type cannot be unambigiously resolved - if (resolvedTypes.length != 1) - Trace.trace(Trace.WARNING, "The type cannot be unambigiously resolved. Need to handle this case"); - String[] resolvedType = resolvedTypes[0]; - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < resolvedType.length - 1; i++) { - buffer.append(resolvedType[i]); - buffer.append('.'); - } - - buffer.append(resolvedType[resolvedType.length - 1]); - - return buffer.toString(); - } -} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/ServletTestCasePropertyTester.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/ServletTestCasePropertyTester.java deleted file mode 100644 index d73704d..0000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/ServletTestCasePropertyTester.java +++ /dev/null
@@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core.internal.cactus; - -import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.server.core.internal.Trace; -/** - * - */ -public class ServletTestCasePropertyTester extends PropertyTester { - public static final String PROPERTY_IS_SERVLET_TEST_CASE = "isServletTestCase"; - private static final String TEST_SUPERCLASS_NAME = "org.apache.cactus.ServletTestCase"; - - public boolean test(Object receiver, String method, Object[] args, Object expectedValue) { - IJavaElement javaElement = null; - if (receiver instanceof IAdaptable) { - javaElement = (IJavaElement) ((IAdaptable) receiver).getAdapter(IJavaElement.class); - } - if (javaElement != null) { - if (!javaElement.exists()) { - return false; - } - } - if (javaElement instanceof IJavaProject - || javaElement instanceof IPackageFragmentRoot - || javaElement instanceof IPackageFragment) { - return true; - } - if (javaElement != null) { - if (PROPERTY_IS_SERVLET_TEST_CASE.equals(method)) { //$NON-NLS-1$ - return isServletTestCase(javaElement); - } - } - return false; - } - - private boolean isServletTestCase(IJavaElement element) { - IType testType = null; - - try { - if (element instanceof ICompilationUnit) { - ICompilationUnit cu = (ICompilationUnit) element; - testType = cu.getType(Signature.getQualifier(cu.getElementName())); - } else if (element instanceof IClassFile) - testType = ((IClassFile) element).getType(); - else if (element instanceof IType) - testType = (IType) element; - else if (element instanceof IMember) - testType = ((IMember) element).getDeclaringType(); - - if (testType != null && testType.exists() && isTestOrSuite(testType)) - return true; - } catch (JavaModelException e) { - Trace.trace(Trace.SEVERE, "Error checking isServlet", e); - } - return false; - } - - /** - * - * @param testType - * @return true if the type is a test, false otherwise - */ - private boolean isTestOrSuite(IType testType) throws JavaModelException { - IType[] types = testType.newSupertypeHierarchy(null).getAllSuperclasses(testType); - for (int i = 0; i < types.length; i++) { - if (types[i].getFullyQualifiedName().equals(TEST_SUPERCLASS_NAME)) { - return true; - } - } - return false; - } -} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/WebTestableResource.java b/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/WebTestableResource.java deleted file mode 100644 index 9e6873a..0000000 --- a/plugins/org.eclipse.jst.server.core/src/org/eclipse/jst/server/core/internal/cactus/WebTestableResource.java +++ /dev/null
@@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core.internal.cactus; - -import org.eclipse.jst.server.core.internal.Messages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.model.ModuleArtifactDelegate; - -public class WebTestableResource extends ModuleArtifactDelegate { - private boolean fServletIsConfigured; - private String fClassName; - private String fTestName; - private String fProjectName; - - public WebTestableResource(IModule module, boolean servletIsConfigured, - String projectName, String className, String testName) { - super(module); - fServletIsConfigured = servletIsConfigured; - fClassName = className; - fTestName = testName; - fProjectName = projectName; - } - - public WebTestableResource() { - super(); - } - - public String getProjectName() { - return fProjectName; - } - - public boolean isServletConfigured() { - return fServletIsConfigured; - } - - public String getClassName() { - return fClassName; - } - - public String getTestName() { - return fTestName; - } - - /* - * @see ModuleArtifactDelegate#getName() - */ - public String getName() { - return NLS.bind(Messages.artifactCactusTest, fTestName); - } - - /* - * @see ModuleArtifactDelegate#deserialize(String) - */ - public void deserialize(String s) { - int ind = s.indexOf("//"); - super.deserialize(s.substring(0, ind)); - s = s.substring(ind+2); - ind = s.indexOf("//"); - fProjectName = s.substring(0, ind); - - s = s.substring(ind+2); - ind = s.indexOf("//"); - fClassName = s.substring(0, ind); - - if ('T' == s.charAt(ind+2)) - fServletIsConfigured = true; - else - fServletIsConfigured = false; - fTestName = s.substring(ind+3); - } - - /* - * @see ModuleArtifactDelegate#serialize() - */ - public String serialize() { - StringBuffer sb = new StringBuffer(super.serialize()); - sb.append("//"); - sb.append(fProjectName); - sb.append("//"); - sb.append(fClassName); - sb.append("//"); - if (fServletIsConfigured) - sb.append("T"); - else - sb.append("F"); - sb.append(fTestName); - return sb.toString(); - } -} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.java index 300a8f4..f6833cd 100644 --- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.java +++ b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2009 IBM Corporation 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 @@ -15,33 +15,8 @@ * Translated messages. */ public class Messages extends NLS { - public static String errorLocation; public static String errorJRE; - public static String classpathContainerDescription; - public static String classpathContainer; - public static String classpathContainerUnbound; - - public static String copyingTask; - public static String deletingTask; - public static String errorCopyingFile; - public static String errorCreatingZipFile; - public static String errorDelete; - public static String errorRename; - public static String errorReading; - public static String updateClasspathContainers; - public static String errorNoRuntime; - public static String errorFacet; - public static String errorDeleting; - public static String errorNotADirectory; - public static String errorMkdir; - - public static String artifactServlet; - public static String artifactEJB; - public static String artifactJNDI; - public static String artifactCactusTest; - public static String canModifyModules; - public static String errorNoProfiler; public static String errorPublish; public static String httpPort; public static String errorPortInUse;
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.properties b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.properties index 76c6ce4..e329bfb 100644 --- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.properties +++ b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.properties
@@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2004, 2007 IBM Corporation and others. +# Copyright (c) 2007, 2009 IBM Corporation 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 @@ -9,36 +9,9 @@ # IBM Corporation - initial API and implementation ############################################################################### -classpathContainerDescription=Server Library -classpathContainer={0} [{1}] -classpathContainerUnbound={0} [{1}] (unbound) - -errorLocation=Invalid location. errorJRE=Invalid JRE. - -copyingTask=Copying from {0} to {1} -deletingTask=Deleting {0} -errorCopyingFile=Error copying file {0}: {1} -errorCreatingZipFile=Error creating zip file {0}: {1} -errorDelete=Could not delete previous copy, which may be locked by another process. -errorRename=Could not replace with temp file {0}. -errorReading=Error reading file {0} -errorNoRuntime=Cannot verify facets because there is no runtime associated with the server. -errorFacet=Project facet {0} version {1} is not supported. -errorDeleting=Could not delete {0}. May be locked by another process. -errorNotADirectory=Could not delete {0} since it is not a directory. -errorMkdir=Could not create directory {0}. - -updateClasspathContainers=Updating classpath container for {0} - -artifactServlet=Servlet {0} -artifactEJB=EJB {0} -artifactJNDI=JNDI {0} -artifactCactusTest=Cactus test {0} - canModifyModules=Web module can be added to the server. -errorNoProfiler=Could not launch in profiling mode because no profilers are configured. -errorPublish=An error occured during publishing. +errorPublish=An error occurred during publishing. httpPort=HTTP Port errorPortInUse=Port {0} required by {1} is already in use. The server may already be running in another process, or a system process may be using the port. \ - To start this server you will need to stop the other process or change the port number(s). \ No newline at end of file + To start this server you will need to stop the other process or change the port number(s).
diff --git a/plugins/org.eclipse.jst.server.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.server.ui/META-INF/MANIFEST.MF index a66ba3d..1b9d944 100644 --- a/plugins/org.eclipse.jst.server.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.jst.server.ui/META-INF/MANIFEST.MF
@@ -2,12 +2,11 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jst.server.ui; singleton:=true -Bundle-Version: 1.0.403.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Activator: org.eclipse.jst.server.ui.internal.JavaServerUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin -Export-Package: org.eclipse.jst.server.ui.internal;x-internal:=true, - org.eclipse.jst.server.ui.internal.cactus;x-internal:=true +Export-Package: org.eclipse.jst.server.ui.internal;x-internal:=true Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
diff --git a/plugins/org.eclipse.jst.server.ui/icons/obj16/new_testcase.gif b/plugins/org.eclipse.jst.server.ui/icons/obj16/new_testcase.gif deleted file mode 100644 index 1ff93cb..0000000 --- a/plugins/org.eclipse.jst.server.ui/icons/obj16/new_testcase.gif +++ /dev/null Binary files differ
diff --git a/plugins/org.eclipse.jst.server.ui/icons/wizban/new_test_wiz.png b/plugins/org.eclipse.jst.server.ui/icons/wizban/new_test_wiz.png deleted file mode 100644 index 78c8755..0000000 --- a/plugins/org.eclipse.jst.server.ui/icons/wizban/new_test_wiz.png +++ /dev/null Binary files differ
diff --git a/plugins/org.eclipse.jst.server.ui/plugin.xml b/plugins/org.eclipse.jst.server.ui/plugin.xml index 9621477..0bc37b7 100644 --- a/plugins/org.eclipse.jst.server.ui/plugin.xml +++ b/plugins/org.eclipse.jst.server.ui/plugin.xml
@@ -40,25 +40,6 @@ class="org.eclipse.jst.server.ui.internal.GenericRuntimeWizardFragment"/> </extension> - <extension point="org.eclipse.wst.server.core.clients"> - <client - id="org.eclipse.jst.server.cactus.client" - class="org.eclipse.jst.server.ui.internal.cactus.JUnitClientDelegate" - launchable="org.eclipse.jst.server.cactus.launchable" - name="%cactusJUnitClient"/> - </extension> - - <extension point="org.eclipse.ui.newWizards"> - <wizard - id="org.eclipse.jst.server.ui.internal.cactus.NewServletTestCaseWizard" - canFinishEarly="false" - category="org.eclipse.jdt.ui.java/org.eclipse.jdt.junit" - class="org.eclipse.jst.server.ui.internal.cactus.NewServletTestCaseWizard" - hasPages="true" - icon="icons/obj16/new_testcase.gif" - name="%cactusServletTestCase"/> - </extension> - <extension point="org.eclipse.wst.common.project.facet.ui.images"> <image runtime-component-type="org.eclipse.jst.server.core.runtimeType" path="icons/obj16/java_jar.gif"/> @@ -80,11 +61,4 @@ </adapter> </extension> - <extension point="org.eclipse.jdt.ui.quickFixProcessors"> - <quickFixProcessor - name="%cactusQuickFixProcessor" - class="org.eclipse.jst.server.ui.internal.cactus.CactusQuickFixProcessor" - id="org.eclipse.jst.server.ui.internal.cactus.CactusQuickFixProcessor"> - </quickFixProcessor> - </extension> </plugin> \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/ImageResource.java b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/ImageResource.java index 7aeeddb..684357d 100644 --- a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/ImageResource.java +++ b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/ImageResource.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. + * Copyright (c) 2003, 2009 IBM Corporation 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 @@ -42,7 +42,6 @@ private static final String URL_WIZBAN = "wizban/"; public static final String IMG_WIZ_RUNTIME_TYPE = "wiz_runtimeType"; - public static final String IMG_WIZ_CACTUS_TEST = "wiz_cactus_test"; /** * Cannot construct an ImageResource. Use static methods only. @@ -83,14 +82,13 @@ imageDescriptors = new HashMap<String, ImageDescriptor>(); registerImage(IMG_WIZ_RUNTIME_TYPE, URL_WIZBAN + "new_runtime_wiz.png"); - registerImage(IMG_WIZ_CACTUS_TEST, URL_WIZBAN + "new_test_wiz.png"); } /** * Register an image with the registry. * - * @param key java.lang.String - * @param partialURL java.lang.String + * @param key the key + * @param partialURL a partial URL */ private static void registerImage(String key, String partialURL) { try {
diff --git a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/Messages.properties b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/Messages.properties index 7de1905..2785a89 100644 --- a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/Messages.properties +++ b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/Messages.properties
@@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2004, 2007 IBM Corporation and others. +# Copyright (c) 2004, 2009 IBM Corporation 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 @@ -22,29 +22,3 @@ classpathContainer=Server Library classpathContainerDescription=Select a server runtime to add to the classpath classpathContainerRuntimeList=Select a &runtime to add to the classpath: - -errorInternalCactus=Internal error while attempting to launch Cactus - -LaunchTestAction_message_selectConfiguration=Select a Test Configuration -LaunchTestAction_message_selectDebugConfiguration=Select JUnit configuration to debug -LaunchTestAction_message_selectRunConfiguration=Select JUnit configuration to run - -NewServletTestCaseWizard_WindowTitle=New Cactus Test Case -NewServletTestCaseWizard_ErrorMessageTitleMissingLibrary=Missing library -NewServletTestCaseWizard_ErrorMessageMissingLibrary=You are missing cactus dependencies in your web project. Would you like to install them? -NewServletTestCaseWizard_ErrorTitleNew=New -NewServletTestCaseWizard_ErrorTitleCreateOfElementFailed=Creation of element failed. -NewServletTestCaseWizard_ErrorMessageSeeErrorLog=See error log for more details. -NewServletTestCaseWizard_WarningMessageSelectAWebProject=Warning: Cactus libraries can only be installed in a web project. Please select a web project. -NewServletTestCaseWizard_WarningTitleWebProjectRequired=Web project required. -NewServletTestCaseWizard_WarningMessageSuperclassIsEmpty=Superclass is empty. -NewServletTestCaseWizard_WarningMessageSuperclassDoesNotExist=Superclass does not exist. -NewServletTestCaseWizard_WarningMessageSuperclassIsInterface=Superclass is interface. -NewServletTestCaseWizard_WarningMessageSuperclassNotServletTestCase=Superclass does not extends org.apache.cactus.ServletTestCase. -CactusAddLibrariesProposal_ErrorMessageCouldntInstallLibraries=Couldn't install libraries -CactusAddLibrariesProposal_ErrorMessageCactusBundleNotFound=Cactus bundle could not be found. -CactusAddLibrariesProposal_ErrorMessageDestDirNotFound=Destination folder did not exist. -CactusAddLibrariesProposal_ErrorMessageInstallationOfLibsFailed=Installation of libraries failed. -CactusAddLibrariesProposal_ErrorMessageInstallDirNotFound=Cactus install directory could not be found -CactusAddLibrariesProposal_AdditionalInfoAddCactusLibraries=Add the Cactus libraries to do the WEB-INF/lib directory -CactusAddLibrariesProposal_DisplayStringAddCactusLibs=Add Cactus Libraries
diff --git a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/CactusAddLibrariesProposal.java b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/CactusAddLibrariesProposal.java deleted file mode 100644 index f85a7b5..0000000 --- a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/CactusAddLibrariesProposal.java +++ /dev/null
@@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.ui.internal.cactus; - -import java.io.File; -import java.io.IOException; -import java.net.URL; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.ui.text.java.IInvocationContext; -import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.contentassist.IContextInformation; -import org.eclipse.jst.server.ui.internal.JavaServerUIPlugin; -import org.eclipse.jst.server.ui.internal.Messages; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.ui.actions.CopyFilesAndFoldersOperation; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.osgi.framework.Bundle; - -public class CactusAddLibrariesProposal implements IJavaCompletionProposal { - private final IInvocationContext fContext; - - public CactusAddLibrariesProposal(IInvocationContext context) { - fContext = context; - } - - public int getRelevance() { - return 0; - } - - public void apply(IDocument document) { - ICompilationUnit javaFile = fContext.getCompilationUnit(); - installLibraries(javaFile.getJavaProject().getProject()); - } - - public static void installLibraries(final IProject project) { - try { - Bundle bundle = Platform.getBundle("org.apache.cactus"); //$NON-NLS-1$ - if (bundle == null) { - showInstallFailedDialog(Messages.CactusAddLibrariesProposal_ErrorMessageCactusBundleNotFound); - return; - } - URL cactusLibDir = FileLocator.find(bundle, new Path("lib"), null); //$NON-NLS-1$ - if (cactusLibDir == null) { - showInstallFailedDialog(Messages.CactusAddLibrariesProposal_ErrorMessageInstallDirNotFound); - return; - } - URL localURL = FileLocator.toFileURL(cactusLibDir); - final File sourceDirectory = new File(localURL.getPath()); - IVirtualComponent component = ComponentCore.createComponent(project); - IVirtualFolder vf = component.getRootFolder().getFolder("WEB-INF/lib"); //$NON-NLS-1$ - final IContainer destinationDirectory = vf.getUnderlyingFolder(); - - IFolder destinationFolder = project.getFolder(destinationDirectory - .getProjectRelativePath()); - - if (destinationFolder.exists()) { - File[] filesToCopy = sourceDirectory.listFiles(); - String[] filesToCopyNames = new String[filesToCopy.length]; - for (int i = 0; i < filesToCopy.length; i++) { - filesToCopyNames[i] = filesToCopy[i].getAbsolutePath(); - } - CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation( - JavaServerUIPlugin.getActiveWorkbenchShell()); - operation.copyFiles(filesToCopyNames, destinationFolder); - } else { - showInstallFailedDialog(Messages.CactusAddLibrariesProposal_ErrorMessageDestDirNotFound); - return; - } - } catch (IOException e) { - JavaServerUIPlugin.log(e); - showInstallFailedDialog(Messages.CactusAddLibrariesProposal_ErrorMessageInstallationOfLibsFailed); - } - } - - private static void showInstallFailedDialog(String message) { - MessageDialog.openError(JavaServerUIPlugin.getActiveWorkbenchShell(), - Messages.CactusAddLibrariesProposal_ErrorMessageCouldntInstallLibraries, - message); //$NON-NLS-1$ //$NON-NLS-2$ - } - - public Point getSelection(IDocument document) { - return new Point(fContext.getSelectionOffset(), fContext.getSelectionLength()); - } - - public String getAdditionalProposalInfo() { - return Messages.CactusAddLibrariesProposal_AdditionalInfoAddCactusLibraries; //$NON-NLS-1$ - } - - public String getDisplayString() { - return Messages.CactusAddLibrariesProposal_DisplayStringAddCactusLibs; //$NON-NLS-1$ - } - - public Image getImage() { - return null; - } - - public IContextInformation getContextInformation() { - return null; - } -} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/CactusQuickFixProcessor.java b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/CactusQuickFixProcessor.java deleted file mode 100644 index b756044..0000000 --- a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/CactusQuickFixProcessor.java +++ /dev/null
@@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.ui.internal.cactus; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.IBuffer; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.compiler.IProblem; -import org.eclipse.jdt.ui.text.java.IInvocationContext; -import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; -import org.eclipse.jdt.ui.text.java.IProblemLocation; -import org.eclipse.jdt.ui.text.java.IQuickFixProcessor; -import org.eclipse.jst.server.ui.internal.JavaServerUIPlugin; - -public class CactusQuickFixProcessor implements IQuickFixProcessor { - - public boolean hasCorrections(ICompilationUnit unit, int problemId) { - return IProblem.ImportNotFound == problemId; - } - - public IJavaCompletionProposal[] getCorrections(IInvocationContext context, - IProblemLocation[] locations) throws CoreException { - if (isCactusProblem(context, locations)) - return new IJavaCompletionProposal[] { new CactusAddLibrariesProposal(context) }; - - return new IJavaCompletionProposal[0]; - } - - private boolean isCactusProblem(IInvocationContext context, IProblemLocation[] locations) { - ICompilationUnit unit = context.getCompilationUnit(); - for (int i = 0; i < locations.length; i++) { - IProblemLocation location = locations[i]; - try { - String s = getStringUntilWhiteSpaceOrEnd(location.getOffset(), unit); - if ("ServletTestCase".equals(s) || s.indexOf("org.apache.cactus") >= 0) - return true; - } catch (JavaModelException e) { - JavaServerUIPlugin.log(e); - } - } - return false; - } - - private String getStringUntilWhiteSpaceOrEnd(int offset, ICompilationUnit unit) throws JavaModelException { - StringBuffer builder = new StringBuffer(); - IBuffer buffer = unit.getBuffer(); - int length = buffer.getLength(); - - for (int index = offset; index < length; index++) { - char c = buffer.getChar(index); - if (Character.isWhitespace(c)) - return builder.toString(); - - builder.append(c); - } - return builder.toString(); - } -} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/JUnitClientDelegate.java b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/JUnitClientDelegate.java deleted file mode 100644 index 2bc9416..0000000 --- a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/JUnitClientDelegate.java +++ /dev/null
@@ -1,170 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.ui.internal.cactus; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.*; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugModelPresentation; -import org.eclipse.jdt.internal.junit.launcher.JUnitLaunchConfigurationConstants; -import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.server.core.internal.cactus.CactusLaunchable; -import org.eclipse.jst.server.ui.internal.JavaServerUIPlugin; -import org.eclipse.jst.server.ui.internal.Messages; -import org.eclipse.ui.dialogs.ElementListSelectionDialog; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.model.ClientDelegate; -/** - * - */ -public class JUnitClientDelegate extends ClientDelegate { - public IStatus launch(IServer server, Object object, String launchMode, ILaunch launch) { - CactusLaunchable launchable = (CactusLaunchable) object; - ILaunchConfiguration config = findLaunchConfiguration(launchable, launchMode); - if (config == null) { - String testName = launchable.getTestName(); - testName = "".equals(testName) ? launchable.getTestClassName() - : launchable.getTestClassName() + "." + testName + "()"; - config = createConfiguration(launchable.getProjectName(), testName, - launchable.getTestClassName(), "", launchable.getTestName()); - } - - URL url = launchable.getCactusURL(); - String urlString = url.toString(); - if (urlString.endsWith("/")) { - try { - url = new URL(urlString.substring(0, urlString.length() - 1)); - } catch (MalformedURLException e) { - return new Status(IStatus.ERROR, JavaServerUIPlugin.PLUGIN_ID, IStatus.ERROR, Messages.errorInternalCactus, e); - } - } - - try { - final ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy(); - String vmArgs; - vmArgs = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, ""); - copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, - vmArgs + " -Dcactus.contextURL=" + url.toString()); - config = copy.doSave(); - DebugUITools.launch(config, launchMode); - } catch (CoreException e) { - return new Status(IStatus.ERROR, JavaServerUIPlugin.PLUGIN_ID, IStatus.ERROR, Messages.errorInternalCactus, e); - } - return Status.OK_STATUS; - } - - protected ILaunchConfiguration createConfiguration(String projectName, - String name, String mainType, String container, String testName) { - ILaunchConfiguration config = null; - try { - ILaunchConfigurationType configType = getJUnitLaunchConfigType(); - ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, - DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name)); - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, mainType); - wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName); - wc.setAttribute(JUnitLaunchConfigurationConstants.ATTR_KEEPRUNNING, false); - wc.setAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_CONTAINER, container); - if (testName.length() > 0) - wc.setAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_METHOD_NAME, testName); - config = wc.doSave(); - } catch (CoreException e) { - JavaServerUIPlugin.log(e); - } - return config; - } - - private ILaunchConfiguration findLaunchConfiguration(CactusLaunchable launchable, String mode) { - String testName = launchable.getTestName(); - String testClass = launchable.getTestClassName(); - String javaProjectName = launchable.getProjectName(); - String container = ""; - ILaunchConfigurationType configType = getJUnitLaunchConfigType(); - List<ILaunchConfiguration> candidateConfigs = new ArrayList<ILaunchConfiguration>(); - try { - ILaunchConfiguration[] configs = DebugPlugin.getDefault() - .getLaunchManager().getLaunchConfigurations(configType); - candidateConfigs = new ArrayList<ILaunchConfiguration>(configs.length); - for (int i = 0; i < configs.length; i++) { - ILaunchConfiguration config = configs[i]; - // we should probably extract the JUnit internal stuff and - // create a new CactusLaunchConfiguration instead - if ((config.getAttribute( - JUnitLaunchConfigurationConstants.ATTR_TEST_CONTAINER, "").equals(container)) && //$NON-NLS-1$ - (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, - "").equals(testClass)) && //$NON-NLS-1$ - (config.getAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_METHOD_NAME, "").equals(testName)) && //$NON-NLS-1$ - (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, - "").equals(javaProjectName))) { //$NON-NLS-1$ - candidateConfigs.add(config); - } - } - } catch (CoreException e) { - JavaServerUIPlugin.log(e); - } - - // If there are no existing configs associated with the IType, create one. - // If there is exactly one config associated with the IType, return it. - // Otherwise, if there is more than one config associated with the IType, - // prompt the user to choose one. - int candidateCount = candidateConfigs.size(); - if (candidateCount < 1) - return null; - else if (candidateCount == 1) - return candidateConfigs.get(0); - else { - // Prompt the user to choose a config. A null result means the user - // cancelled the dialog, in which case this method returns null, - // since cancelling the dialog should also cancel launching anything. - ILaunchConfiguration config = chooseConfiguration(candidateConfigs, mode); - if (config != null) - return config; - } - return null; - } - - protected ILaunchConfiguration chooseConfiguration(List configList, String mode) { - IDebugModelPresentation labelProvider = DebugUITools - .newDebugModelPresentation(); - ElementListSelectionDialog dialog = new ElementListSelectionDialog( - JavaServerUIPlugin.getActiveWorkbenchShell(), labelProvider); - dialog.setElements(configList.toArray()); - dialog.setTitle(Messages.LaunchTestAction_message_selectConfiguration); - if (mode.equals(ILaunchManager.DEBUG_MODE)) - dialog.setMessage(Messages.LaunchTestAction_message_selectDebugConfiguration); - else - dialog.setMessage(Messages.LaunchTestAction_message_selectRunConfiguration); - - dialog.setMultipleSelection(false); - int result = dialog.open(); - labelProvider.dispose(); - if (result == Window.OK) - return (ILaunchConfiguration) dialog.getFirstResult(); - - return null; - } - - protected ILaunchConfigurationType getJUnitLaunchConfigType() { - // might want to replace this with a custom launch configuration instead - ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager(); - return lm.getLaunchConfigurationType("org.eclipse.jdt.junit.launchconfig"); - } - - public boolean supports(IServer server, Object launchable, String launchMode) { - return launchable instanceof CactusLaunchable; - } -} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/NewServletTestCaseWizard.java b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/NewServletTestCaseWizard.java deleted file mode 100644 index bf6e095..0000000 --- a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/cactus/NewServletTestCaseWizard.java +++ /dev/null
@@ -1,492 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 BEA Systems, Inc. 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: - * Daniel R. Somerfield - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.ui.internal.cactus; - -import java.io.StringWriter; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne; -import org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageTwo; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jst.server.ui.internal.ImageResource; -import org.eclipse.jst.server.ui.internal.JavaServerUIPlugin; -import org.eclipse.jst.server.ui.internal.Messages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -/** - * - */ -public class NewServletTestCaseWizard extends Wizard implements INewWizard { - private static final String SUPERCLASS_NAME = "org.apache.cactus.ServletTestCase"; //$NON-NLS-1$ - - protected static final String[] CLASSES_TO_CHECK = { - "org.apache.cactus.ServletTestCase", "junit.framework.TestCase", //$NON-NLS-1$ //$NON-NLS-2$ - "org.apache.commons.logging.Log", "org.aspectj.lang.JoinPoint", //$NON-NLS-1$ //$NON-NLS-2$ - "org.apache.commons.httpclient.HttpClient" }; //$NON-NLS-1$ - - protected static final String[] REQUIRED_LIBRARIES = { - "cactus-1.7.2.jar", "junit-3.8.1.jar", "aspectjrt-1.2.1.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - "commons-logging-1.0.4.jar", "commons-httpclient-2.0.2.jar" }; //$NON-NLS-1$ //$NON-NLS-2$ - - private IWorkbench fWorkbench; - - private IStructuredSelection fSelection; - - private NewTestCaseWizardPageTwo fPage2; - - private NewTestCaseWizardPageOne fPage1; - - public NewServletTestCaseWizard() { - super(); - setWindowTitle(Messages.NewServletTestCaseWizard_WindowTitle); - setDefaultPageImageDescriptor(ImageResource - .getImageDescriptor(ImageResource.IMG_WIZ_CACTUS_TEST)); - } - - public void init(IWorkbench workbench, IStructuredSelection selection) { - fWorkbench = workbench; - fSelection = selection; - } - - public void addPages() { - super.addPages(); - fPage2 = new NewTestCaseWizardPageTwo(); - fPage1 = new CactusPage1(fPage2); - addPage(fPage1); - fPage1.init(getSelection()); - addPage(fPage2); - } - - private class CactusPage1 extends NewTestCaseWizardPageOne { - private Button fBeginButton; - - private Button fEndButton; - - private Button fBeginXXXButton; - - private Button fEndXXXButton; - - private Composite fCactusButtonComposite; - - public CactusPage1(NewTestCaseWizardPageTwo page2) { - super(page2); - } - - public void init(IStructuredSelection selection) { - super.init(selection); - validateIfJUnitProject(); - } - - public void createControl(Composite parent) { - super.createControl(parent); - setSuperClass(SUPERCLASS_NAME, true); - } - - protected void createJUnit4Controls(Composite composite, int nColumns) { - // ignore - } - - protected IStatus superClassChanged() { - String superClassName = getSuperClass(); - if (superClassName == null || superClassName.trim().equals("")) { //$NON-NLS-1$ - Status status = new Status(IStatus.ERROR, JavaServerUIPlugin.PLUGIN_ID, - IStatus.ERROR, - Messages.NewServletTestCaseWizard_WarningMessageSuperclassIsEmpty, null); - return status; - } - - if (superClassName.equals("org.apache.cactus.ServletTestCase")) { - //Short-circuit if this IS ServletTestCase - return Status.OK_STATUS; - } - - if (getPackageFragmentRoot() != null) { - IType type; - try { - type = resolveClassNameToType(getPackageFragmentRoot().getJavaProject(), - getPackageFragment(), superClassName); - if (type == null) { - Status status = new Status( - IStatus.WARNING, - JavaServerUIPlugin.PLUGIN_ID, - IStatus.WARNING, - Messages.NewServletTestCaseWizard_WarningMessageSuperclassDoesNotExist, - null); - return status; - } - - if (type.isInterface()) { - Status status = new Status( - IStatus.WARNING, - JavaServerUIPlugin.PLUGIN_ID, - IStatus.WARNING, - Messages.NewServletTestCaseWizard_WarningMessageSuperclassIsInterface, - null); - return status; - } - - ITypeHierarchy hierarchy = type.newTypeHierarchy(null); - IType[] superTypes = hierarchy.getAllSuperclasses(type); - for (int i = 0; i < superTypes.length; i++) { - if (superTypes[i].getFullyQualifiedName().equals( - "org.apache.cactus.ServletTestCase")) { - return Status.OK_STATUS; - } - } - - Status status = new Status( - IStatus.WARNING, - JavaServerUIPlugin.PLUGIN_ID, - IStatus.WARNING, - Messages.NewServletTestCaseWizard_WarningMessageSuperclassNotServletTestCase, - null); - return status; - - } catch (JavaModelException e) { - JavaServerUIPlugin.log(e); - } - } - - return Status.OK_STATUS; - } - - private IType resolveClassNameToType(IJavaProject jproject, IPackageFragment pack, - String classToTestName) throws JavaModelException { - - IType type = jproject.findType(classToTestName); - - // search in current package - if (type == null && pack != null && !pack.isDefaultPackage()) { - type = jproject.findType(pack.getElementName(), classToTestName); - } - - // search in java.lang - if (type == null) { - type = jproject.findType("java.lang", classToTestName); //$NON-NLS-1$ - } - return type; - } - - protected IStatus validateIfJUnitProject() { - try { - if (checkForWebProject()) { - checkForCactusLibraries(); - } else { - String msg = Messages.NewServletTestCaseWizard_WarningMessageSelectAWebProject; - MessageDialog.openWarning(getShell(), - Messages.NewServletTestCaseWizard_WarningTitleWebProjectRequired, - msg); - return new Status(IStatus.WARNING, JavaServerUIPlugin.PLUGIN_ID, - IStatus.ERROR, msg, null); - } - } catch (CoreException e) { - return new Status(IStatus.ERROR, JavaServerUIPlugin.PLUGIN_ID, IStatus.ERROR, - "Failed to check for cactus libraries.", e); - } - - return Status.OK_STATUS; - } - - protected void createTypeMembers(IType type, ImportsManager imports, - IProgressMonitor monitor) throws CoreException { - super.createTypeMembers(type, imports, monitor); - if (fBeginButton.getSelection()) { - generateBeginMethod(type, imports); - } - - if (fEndButton.getSelection()) { - generateEndMethod(type, imports); - } - - if (fBeginXXXButton.getSelection()) { - generateBeginXXXMethods(type, imports); - } - - if (fEndXXXButton.getSelection()) { - generateEndXXXMethods(type, imports); - } - } - - private void generateBeginMethod(IType type, ImportsManager imports) - throws JavaModelException { - StringBuffer methodBuffer = new StringBuffer(); - methodBuffer.append("public void begin("); //$NON-NLS-1$ - methodBuffer.append(imports.addImport("org.apache.cactus.WebRequest")); //$NON-NLS-1$ - methodBuffer.append(" request) throws "); //$NON-NLS-1$ - methodBuffer.append(imports.addImport("java.lang.Exception")); //$NON-NLS-1$ - methodBuffer.append(" {\n\n\t} "); //$NON-NLS-1$ - type.createMethod(methodBuffer.toString(), null, false, null); - } - - private void generateEndMethod(IType type, ImportsManager imports) - throws JavaModelException { - StringBuffer methodBuffer = new StringBuffer(); - methodBuffer.append("public void end("); //$NON-NLS-1$ - methodBuffer.append(imports.addImport("org.apache.cactus.WebRequest")); //$NON-NLS-1$ - methodBuffer.append(" request) throws "); //$NON-NLS-1$ - methodBuffer.append(imports.addImport("java.lang.Exception")); //$NON-NLS-1$ - methodBuffer.append(" {\n\n\t} "); //$NON-NLS-1$ - type.createMethod(methodBuffer.toString(), null, false, null); - } - - private void generateBeginXXXMethods(IType type, ImportsManager imports) - throws JavaModelException { - generateXXXMethods(type, imports, "begin"); //$NON-NLS-1$ - } - - private void generateXXXMethods(IType type, ImportsManager imports, String prefix) - throws JavaModelException { - IMethod[] testMethods = type.getMethods(); - for (int i = 0; i < testMethods.length; i++) { - IMethod testMethod = testMethods[i]; - String testMethodName = testMethod.getElementName(); - if (testMethodName.startsWith("test")) //$NON-NLS-1$ - { - String newMethodName = prefix + testMethodName.substring(4); - StringBuffer methodBuffer = new StringBuffer(); - methodBuffer.append("public void "); //$NON-NLS-1$ - methodBuffer.append(newMethodName); - methodBuffer.append("("); //$NON-NLS-1$ - methodBuffer.append(imports.addImport("org.apache.cactus.WebRequest")); //$NON-NLS-1$ - methodBuffer.append(" request) throws "); //$NON-NLS-1$ - methodBuffer.append(imports.addImport("java.lang.Exception")); //$NON-NLS-1$ - methodBuffer.append(" {\n\n\t} "); //$NON-NLS-1$ - type.createMethod(methodBuffer.toString(), testMethod, false, null); - } - } - } - - private void generateEndXXXMethods(IType type, ImportsManager imports) - throws JavaModelException { - generateXXXMethods(type, imports, "end"); //$NON-NLS-1$ - } - - protected void createMethodStubSelectionControls(Composite composite, int nColumns) { - super.createMethodStubSelectionControls(composite, nColumns); - createEmptySpace(composite); - fCactusButtonComposite = new Composite(composite, SWT.NONE); - GridData gd = new GridData(); - gd.horizontalSpan = 3; - fCactusButtonComposite.setLayoutData(gd); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginWidth = layout.marginHeight = 0; - layout.makeColumnsEqualWidth = true; - fCactusButtonComposite.setLayout(layout); - - fBeginButton = createSelectionButton("begin()", fCactusButtonComposite); //$NON-NLS-1$ - fEndButton = createSelectionButton("end()", fCactusButtonComposite); //$NON-NLS-1$ - fBeginXXXButton = createSelectionButton( - "beginXXX() methods", fCactusButtonComposite); //$NON-NLS-1$ - fEndXXXButton = createSelectionButton("endXXX() methods", fCactusButtonComposite); //$NON-NLS-1$ - } - - private Button createSelectionButton(String text, Composite group) { - Button button = new Button(group, SWT.CHECK | SWT.LEFT); - button.setFont(group.getFont()); - button.setText(text); - GridData data = new GridData(); - data.horizontalAlignment = SWT.BEGINNING; - data.verticalAlignment = GridData.CENTER; - button.setLayoutData(data); - return button; - } - } - - protected static Control createEmptySpace(Composite parent) { - return createEmptySpace(parent, 1); - } - - private static Control createEmptySpace(Composite parent, int span) { - Label label = new Label(parent, SWT.LEFT); - GridData gd = new GridData(); - gd.horizontalAlignment = GridData.BEGINNING; - gd.grabExcessHorizontalSpace = false; - gd.horizontalSpan = span; - gd.horizontalIndent = 0; - gd.widthHint = 0; - gd.heightHint = 0; - label.setLayoutData(gd); - return label; - } - - private IStructuredSelection getSelection() { - return fSelection; - } - - protected boolean checkForWebProject() throws CoreException { - IPackageFragmentRoot root = fPage1.getPackageFragmentRoot(); - if (root == null) - return false; - - IJavaProject project = root.getJavaProject(); - IFacetedProject facetedProject = ProjectFacetsManager.create(project.getProject()); - if (facetedProject != null) { - Iterator facets = facetedProject.getProjectFacets().iterator(); - while (facets.hasNext()) { - IProjectFacetVersion facet = (IProjectFacetVersion) facets.next(); - if (facet.getProjectFacet().getId().equals("jst.web")) //$NON-NLS-1$ - return true; - } - } - - return false; - } - - protected void checkForCactusLibraries() { - IPackageFragmentRoot root = fPage1.getPackageFragmentRoot(); - if (root == null) - return; - - IJavaProject project = root.getJavaProject(); - - List<String> missingLibraries = new ArrayList<String>(); - try { - for (int i = 0; i < CLASSES_TO_CHECK.length; i++) { - IType type = project.findType(CLASSES_TO_CHECK[i]); - if (type == null) { - missingLibraries.add(REQUIRED_LIBRARIES[i]); - } - } - - if (missingLibraries.size() > 0) { - if (MessageDialog.openQuestion(getShell(), - Messages.NewServletTestCaseWizard_ErrorMessageTitleMissingLibrary, - NLS.bind(Messages.NewServletTestCaseWizard_ErrorMessageMissingLibrary, - missingLibraries.toArray()))) { - CactusAddLibrariesProposal.installLibraries(project.getProject()); - } - } - } catch (JavaModelException e) { - JavaServerUIPlugin.log(e); - } - } - - public boolean performFinish() { - if (finishPage(fPage1.getRunnable())) { - IType newClass = fPage1.getCreatedType(); - - IResource resource = newClass.getCompilationUnit().getResource(); - if (resource != null) { - BasicNewResourceWizard.selectAndReveal(resource, fWorkbench - .getActiveWorkbenchWindow()); - openResource(resource); - } - return true; - } - return false; - } - - protected boolean finishPage(IRunnableWithProgress runnable) { - IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable); - try { - PlatformUI.getWorkbench().getProgressService().runInUI(getContainer(), op, - ResourcesPlugin.getWorkspace().getRoot()); - } catch (InvocationTargetException e) { - String title = Messages.NewServletTestCaseWizard_ErrorTitleNew; // NewJUnitWizard_op_error_title - String message = Messages.NewServletTestCaseWizard_ErrorTitleCreateOfElementFailed; // NewJUnitWizard_op_error_message - displayMessageDialog(e, e.getMessage(), getShell(), title, message); - return false; - } catch (InterruptedException e) { - return false; - } - return true; - } - - public static void displayMessageDialog(Throwable t, String exceptionMessage, - Shell shell, String title, String message) { - StringWriter msg = new StringWriter(); - if (message != null) { - msg.write(message); - msg.write("\n\n"); //$NON-NLS-1$ - } - if (exceptionMessage == null || exceptionMessage.length() == 0) - msg.write(Messages.NewServletTestCaseWizard_ErrorMessageSeeErrorLog); - else - msg.write(exceptionMessage); - MessageDialog.openError(shell, title, msg.toString()); - } - - protected void openResource(final IResource resource) { - if (resource.getType() == IResource.FILE) { - final IWorkbenchPage activePage = getActivePage(); - if (activePage != null) { - final Display display = Display.getDefault(); - if (display != null) { - display.asyncExec(new Runnable() { - public void run() { - try { - IDE.openEditor(activePage, (IFile) resource, true); - } catch (PartInitException e) { - JavaServerUIPlugin.log(e); - } - } - }); - } - } - } - } - - private static IWorkbenchPage getActivePage() { - IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow(); - if (activeWorkbenchWindow == null) - return null; - return activeWorkbenchWindow.getActivePage(); - } - - private static IWorkbenchWindow getActiveWorkbenchWindow() { - IWorkbench workbench = JavaServerUIPlugin.getInstance().getWorkbench(); - if (workbench != null) - return workbench.getActiveWorkbenchWindow(); - - return null; - } -} \ No newline at end of file