Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.ant.tests.ui.debug;

import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getIFile;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchConfiguration;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchManager;
import static org.junit.Assert.assertNotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.ant.tests.ui.debug;

import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getIFile;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchConfiguration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.ant.tests.ui.debug;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getIFile;

import org.eclipse.ant.internal.launching.debug.model.AntThread;
import org.eclipse.core.resources.IFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*******************************************************************************/
package org.eclipse.ant.tests.ui.editor;

import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getIFile;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import static java.util.function.Function.identity;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getBuildFile;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getIFile;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.ant.tests.ui.editor;

import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getIFile;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.ant.tests.ui.editor.formatter;

import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getBuildFile;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getReaderContentAsString;
import static org.junit.Assert.assertEquals;

import java.nio.file.Files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@
package org.eclipse.ant.tests.ui;

import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.IHyperlink;
import org.junit.Rule;

public abstract class AbstractAntUIBuildTest extends AbstractAntUITest {

@Rule
public RunInSeparateThreadRule runInSeparateThread = new RunInSeparateThreadRule();

protected void activateLink(final IHyperlink link) {
Display.getDefault().asyncExec(() -> link.linkActivated());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.eclipse.ant.tests.ui;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getBuildFile;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;

import org.eclipse.ant.internal.ui.AntUtil;
import org.eclipse.ant.internal.ui.preferences.FileFilter;
import org.eclipse.ant.internal.ui.views.actions.AddBuildFilesAction;
import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
Expand Down Expand Up @@ -108,4 +111,54 @@ boolean canAccept(String extn) {
}
}

/**
* This is to help in increasing the test coverage by enabling access to fields
* and execution of methods irrespective of their Java language access
* permissions.
*
* More accessor methods can be added to this on a need basis
*/
private static abstract class TypeProxy {

Object master = null;

protected TypeProxy(Object obj) {
master = obj;
}

/**
* Gets the method with the given method name and argument types.
*
* @param methodName the method name
* @param types the argument types
* @return the method
*/
protected Method get(String methodName, Class<?>[] types) {
Method method = null;
try {
method = master.getClass().getDeclaredMethod(methodName, types);
} catch (SecurityException | NoSuchMethodException e) {
fail();
}
Assert.isNotNull(method);
method.setAccessible(true);
return method;
}

/**
* Invokes the given method with the given arguments.
*
* @param method the given method
* @param arguments the method arguments
* @return the method return value
*/
protected Object invoke(Method method, Object[] arguments) {
try {
return method.invoke(master, arguments);
} catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
fail();
}
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@

package org.eclipse.ant.tests.ui;

import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.activateLink;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getBuildFile;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getColorAtOffset;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getHyperlink;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchConfiguration;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getProject;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.launch;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.launchAndTerminate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@

package org.eclipse.ant.tests.ui.separateVM;

import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.activateLink;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getColorAtOffset;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getHyperlink;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getJavaProject;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchConfiguration;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getProject;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.launch;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.launchAndTerminate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand All @@ -36,7 +40,6 @@
import org.eclipse.ant.launching.IAntLaunchConstants;
import org.eclipse.ant.tests.ui.AbstractAntUIBuildTest;
import org.eclipse.ant.tests.ui.debug.TestAgainException;
import org.eclipse.ant.tests.ui.testplugin.AntUITestUtil;
import org.eclipse.ant.tests.ui.testplugin.ConsoleLineTracker;
import org.eclipse.ant.tests.ui.testplugin.ProjectHelper;
import org.eclipse.core.resources.IFile;
Expand Down Expand Up @@ -311,7 +314,7 @@ public void testFailInputHandler() throws CoreException {
assertNotNull("Could not locate launch configuration for " + "echoingSepVM", config); //$NON-NLS-1$ //$NON-NLS-2$
ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
copy.setAttribute(IAntUIConstants.SET_INPUTHANDLER, false);
AntUITestUtil.launch(copy);
launch(copy);
String message = ConsoleLineTracker.getMessage(1);
assertNotNull("There must be a message", message); //$NON-NLS-1$
assertTrue("Incorrect message. Should start with Message:. Message: " + message, message.startsWith("echo1")); //$NON-NLS-1$ //$NON-NLS-2$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.ant.tests.ui.externaltools;

import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getBuildFile;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchManager;
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getProject;
import static org.junit.Assert.assertFalse;
Expand Down Expand Up @@ -384,7 +385,8 @@ public void testConfigureTriggers10() throws Exception {
*/
@Test
public void testIsUnmigratedConfig1() throws Exception {
ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE);
ILaunchConfigurationType type = getLaunchManager()
.getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE);
if (type != null) {
ILaunchConfigurationWorkingCopy config = type.newInstance(BuilderCoreUtils.getBuilderFolder(getProject(), true), "testIsUnmigratedConfig1"); //$NON-NLS-1$
assertTrue("should be considered 'unmigrated'", BuilderCoreUtils.isUnmigratedConfig(config)); //$NON-NLS-1$
Expand Down
Loading
Loading