Commit ea754e69 authored by Pakulin's avatar Pakulin
Browse files

removed internal tools from release

parent 7a54d657
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>NewTestCaseFeature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="org.etsi.mts.ttcn3.part9.newTestCase"
label="New Test Case"
version="0.0.5.qualifier"
provider-name="STF 475">
<description url="http://www.example.com/description">
[Enter Feature Description here.]
</description>
<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
</copyright>
<license url="http://www.example.com/license">
[Enter License Description here.]
</license>
<plugin
id="org.etsi.mts.ttcn3.part9.newTestCase"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>NewTestCase</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
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.5
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: New Test Case
Bundle-SymbolicName: org.etsi.mts.ttcn3.part9.newTestCase;singleton:=true
Bundle-Version: 0.0.5.qualifier
Bundle-Activator: org.etsi.mts.ttcn3.part9.popup.actions.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: STF 475
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.resources.IFolder"
id="NewTestCase.contribution1">
<menu
label="New Test Case"
path="additions"
id="NewTestCase.menu1">
<separator
name="group1">
</separator>
</menu>
<action
label="Positive"
class="org.etsi.mts.ttcn3.part9.popup.actions.NewPositiveTestCase"
menubarPath="NewTestCase.menu1/group1"
definitionId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newPositiveTestcase"
enablesFor="1"
id="NewTestCase.newAction1">
</action>
<action
label="Negative"
definitionId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newNegativeTestcase"
class="org.etsi.mts.ttcn3.part9.popup.actions.NewNegativeTestCase"
menubarPath="NewTestCase.menu1/group1"
enablesFor="1"
id="NewTestCase.newAction2">
</action>
</objectContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<category
id="org.etsi.mts.ttcn3.part9.newTestCase.commands.category"
name="Sample Category">
</category>
<command
categoryId="org.etsi.mts.ttcn3.part9.newTestCase.commands.category"
id="org.etsi.mts.ttcn3.part9.newTestCase.commands.sampleCommand"
name="Sample Command">
</command>
<command
name="New Positive Testcase"
categoryId="org.eclipse.ui.category.navigate"
id="org.etsi.mts.ttcn3.part9.newTestCase.commands.newPositiveTestcase">
</command>
<command
name="New Negative Testcase"
categoryId="org.eclipse.ui.category.navigate"
id="org.etsi.mts.ttcn3.part9.newTestCase.commands.newNegativeTestcase">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="org.etsi.mts.ttcn3.part9.newtestcase.handlers.CommandHandler"
commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.sampleCommand">
</handler>
<handler
class="org.etsi.mts.ttcn3.part9.newtestcase.handlers.NewPositiveTestCaseHandler"
commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newPositiveTestcase">
</handler>
<handler
class="org.etsi.mts.ttcn3.part9.newtestcase.handlers.NewNegativeTestCaseHandler"
commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newNegativeTestcase">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.sampleCommand"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+6">
</key>
<key
sequence="M1+O"
commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newPositiveTestcase"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
sequence="M1+L"
commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newNegativeTestcase"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
id="org.etsi.mts.ttcn3.part9.newTestCase.menus.sampleMenu"
label="Sample Menu"
mnemonic="M">
<command
commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.sampleCommand"
id="org.etsi.mts.ttcn3.part9.newTestCase.menus.sampleCommand"
mnemonic="S">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="org.etsi.mts.ttcn3.part9.newTestCase.toolbars.sampleToolbar">
<command
commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.sampleCommand"
icon="icons/sample.gif"
id="org.etsi.mts.ttcn3.part9.newTestCase.toolbars.sampleCommand"
tooltip="Say hello world">
</command>
</toolbar>
</menuContribution>
</extension>
</plugin>
package org.etsi.mts.ttcn3.part9.newtestcase.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.jface.dialogs.MessageDialog;
/**
* Our sample handler extends AbstractHandler, an IHandler base class.
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
public class CommandHandler extends AbstractHandler {
/**
* The constructor.
*/
public CommandHandler() {
}
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
MessageDialog.openInformation(
window.getShell(),
"New Test Case",
"Try Me!");
return null;
}
}
package org.etsi.mts.ttcn3.part9.newtestcase.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.etsi.mts.ttcn3.part9.popup.actions.NewNegativeTestCase;
import org.etsi.mts.ttcn3.part9.popup.actions.NewTestCase;
/**
* Our sample handler extends AbstractHandler, an IHandler base class.
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
public class NewNegativeTestCaseHandler extends AbstractHandler {
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
NewTestCase tc = new NewNegativeTestCase();
tc.runAsCommand();
return null;
}
}
package org.etsi.mts.ttcn3.part9.newtestcase.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.etsi.mts.ttcn3.part9.popup.actions.NewPositiveTestCase;
import org.etsi.mts.ttcn3.part9.popup.actions.NewTestCase;
/**
* Our sample handler extends AbstractHandler, an IHandler base class.
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
public class NewPositiveTestCaseHandler extends AbstractHandler {
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
NewTestCase tc = new NewPositiveTestCase();
tc.runAsCommand();
return null;
}
}
package org.etsi.mts.ttcn3.part9.popup.actions;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "NewTestCase"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns an image descriptor for the image file at the given
* plug-in relative path
*
* @param path the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
package org.etsi.mts.ttcn3.part9.popup.actions;
public class NewNegativeTestCase extends NewTestCase {
public NewNegativeTestCase() {
super(TCKind.Neg);
}
}
package org.etsi.mts.ttcn3.part9.popup.actions;
public class NewPositiveTestCase extends NewTestCase {
public NewPositiveTestCase() {
super(TCKind.Pos);
}
}
package org.etsi.mts.ttcn3.part9.popup.actions;
import java.io.ByteArrayInputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
public class NewTestCase implements IObjectActionDelegate {
private Shell shell;
protected TCKind tckind = TCKind.Pos;
protected ISelection selection;
private static final String TTCN_TEMPLATE = "/***************************************************\n"
+ " ** @author STF 475\n"
+ " ** @version 0.0.1\n"
+ " ** @purpose 9:%1$s, TODO write purpose\n"
+ " ** @verdict pass %4$s\n"
+ " ***************************************************/\n"
+ "module %2$s {\n"
+ "\n"
+ " import from schema_%2$s language \"XSD\" all;\n"
+ " // TODO specify type for the template\n"
+ " template __type__ m_msg := omit;\n"
+ "\n"
+ "//#TC%3$s\n"
+"}\n";
private static final String XSD_TEMPLATE =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\"\n"
+ " targetNamespace=\"schema:%1$s\"\n"
+ " xmlns:ns=\"schema:%1$s\">\n"
+ " <!-- TODO Generated Schema stub -->\n"
+ "</schema>";
private static final String XML_TEMPLATE =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!-- xmlns=\"schema:%1$s\" -->\n"
+ "<!-- TODO Generated XML stub -->\n";
/**
* Constructor for generic action.
*/
public NewTestCase(TCKind kind) {
super();
this.tckind = kind;
}
/**
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
shell = targetPart.getSite().getShell();
}
public void run(IAction action) {
createTestCase();
}
//this has to be called if this is executed as command because only as action the selection and
//the shell are updated automatically
public void runAsCommand() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
shell = window.getShell();
selection = window.getSelectionService().getSelection();
}
createTestCase();
}
/**
* @see IActionDelegate#run(IAction)
*/
private void createTestCase() {
if (selection == null) {
MessageDialog.openError(shell, "New test case", "Unsupported explorer view or no selection");
return;
}
TreePath[] paths = ((TreeSelection) selection).getPaths();
TreePath p = paths[0];
IFolder folder = (IFolder) p.getLastSegment();
String name = guessTCName(folder);
if (name == null) {
MessageDialog.openInformation(
shell,
"NewTestCase",
"New Action was executed, but the folder is full");
return;
}
createFiles(folder, name);
}
private boolean createFiles(IFolder folder, String name) {
IFolder tcfolder = folder.getFolder(name);
NullProgressMonitor pm = new NullProgressMonitor();
String section = getSectionString(folder.getName());
try{
pm.beginTask("New test case", 4);
tcfolder.create(true, true, new NullProgressMonitor());
pm.worked(1);
String tcMacroSuffix = TCKind.Neg.equals(tckind) ? "_Neg" : "";
String tcVerdict = TCKind.Neg.equals(tckind) ? "reject" : "accept, ttcn3verdict:pass";
// TODO get section number
String ttcn_content = String.format(TTCN_TEMPLATE, section, name, tcMacroSuffix, tcVerdict);
String xsd_content = String.format(XSD_TEMPLATE, name);
String xml_content = String.format(XML_TEMPLATE, name);
if (pm.isCanceled()) return false;
createFile(tcfolder, ".ttcn_", ttcn_content, pm);
if (pm.isCanceled()) return false;
createFile(tcfolder, ".xsd", xsd_content, pm);
if (pm.isCanceled()) return false;
createFile(tcfolder, ".xml", xml_content, pm);
} catch (CoreException e) {
MessageDialog.openError(shell, "New test case", "Failed to create a test case\n"+e.getLocalizedMessage());
return false;
} finally {
pm.done();
}
return true;
}
private String getSectionString(String name) {
Pattern regex = Pattern.compile("^([0-9]+)_");
String section = "0.0.0.";
Matcher matcher = regex.matcher(name);
if (matcher.find()) {
String rawSection = matcher.group(1);
StringBuilder result = new StringBuilder();
int start = 0, end = rawSection.length();
for (; start < end; start += 2) {
if (start > 0) result.append('.');
char ch1 = rawSection.charAt(start);
if (ch1 != '0') {
result.append(ch1);
}
if (start + 1 < end) {
result.append(rawSection.charAt(start+1));
}
}
section = result.toString();
}
return section;