Skip to content

Commit

Permalink
Merge branch 'v0.15.x_bugfix' into v0.15.x
Browse files Browse the repository at this point in the history
  • Loading branch information
S1artie committed Jun 1, 2016
2 parents dd6f821 + 6d025ae commit 136b2d9
Show file tree
Hide file tree
Showing 10 changed files with 376 additions and 184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
Expand Down Expand Up @@ -46,11 +50,12 @@ public boolean parseURL(String anURL) {
Matcher tempMatcher = INTEGRITY_URL_PATTERN.matcher(anURL);
if (tempMatcher.matches()) {
String tempSuiteName = tempMatcher.group(1);
IEditorPart tempEditor = integritySearch.openSuiteDefinitionByName(tempSuiteName);
boolean tempHasLineNumber = tempMatcher.groupCount() > 1 && tempMatcher.group(2) != null;
IEditorPart tempEditor = integritySearch.openSuiteDefinitionByName(tempSuiteName, !tempHasLineNumber);
if (tempEditor == null) {
showError("Could not find a suite named '" + tempSuiteName + "' in your workspace.");
} else {
if (tempMatcher.groupCount() > 1) {
if (tempHasLineNumber) {
int tempLineNumber = Integer.parseInt(tempMatcher.group(2));
if (!jumpToLine(tempEditor, tempLineNumber)) {
showError("Could not find line number " + tempLineNumber + " in suite '" + tempSuiteName + "'");
Expand Down Expand Up @@ -78,19 +83,40 @@ private boolean jumpToLine(IEditorPart anEditor, int aLineNumber) {
if (!(anEditor instanceof ITextEditor) || aLineNumber <= 0) {
return false;
}
ITextEditor tempEditor = (ITextEditor) anEditor;
final ITextEditor tempEditor = (ITextEditor) anEditor;
IDocument tempDocument = tempEditor.getDocumentProvider().getDocument(tempEditor.getEditorInput());
if (tempDocument != null) {
IRegion tempLineInfo = null;
try {
tempLineInfo = tempDocument.getLineInformation(aLineNumber - 1);
final IRegion tempLineInfo = tempDocument.getLineInformation(aLineNumber - 1);

if (tempLineInfo != null) {
// This is performed asynchronously because Xtext does it in the same way since 2.8 or so.
// The Xtext change originally caused issue #110: Jumping to test/call/suite invocations via
// integrity:// URLs jumps to suitedef instead
Job selectAndRevealJob = new Job("Select and reveal line " + aLineNumber) {
@Override
protected IStatus run(IProgressMonitor monitor) {
tempEditor.getSite().getWorkbenchWindow().getWorkbench().getDisplay()
.asyncExec(new Runnable() {
@Override
public void run() {
tempEditor.selectAndReveal(tempLineInfo.getOffset(),
tempLineInfo.getLength());

}
});
return Status.OK_STATUS;
}
};
selectAndRevealJob.setSystem(true);
selectAndRevealJob.setPriority(Job.SHORT);
selectAndRevealJob.schedule();

return true;
} else {
return false;
}
} catch (BadLocationException exc) {
// ignored
}
if (tempLineInfo != null) {
tempEditor.selectAndReveal(tempLineInfo.getOffset(), tempLineInfo.getLength());
return true;
} else {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public class DefaultIntegritySearch implements IntegritySearch {
public SuiteDefinition[] findSuiteDefinitionByName(String aSuiteName) {
List<SuiteDefinition> tempResult = new ArrayList<SuiteDefinition>();

for (IEObjectDescription tempDesc : searchEngine.findMatches(aSuiteName, SuiteDefinition.class.getSimpleName())) {
for (IEObjectDescription tempDesc : searchEngine.findMatches(aSuiteName,
SuiteDefinition.class.getSimpleName())) {
EObject tempObject = tempDesc.getEObjectOrProxy();
if (tempObject instanceof SuiteDefinition) {
SuiteDefinition tempDefinition = (SuiteDefinition) tempObject;
Expand All @@ -61,10 +62,10 @@ public SuiteDefinition[] findSuiteDefinitionByName(String aSuiteName) {
}

@Override
public IEditorPart openSuiteDefinitionByName(String aSuiteName) {
public IEditorPart openSuiteDefinitionByName(String aSuiteName, boolean aSelectFlag) {
SuiteDefinition[] tempSuiteDef = findSuiteDefinitionByName(aSuiteName);
if (tempSuiteDef != null) {
return uriEditorOpener.open(EcoreUtil.getURI(tempSuiteDef[0]), true);
return uriEditorOpener.open(EcoreUtil.getURI(tempSuiteDef[0]), aSelectFlag);
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public interface IntegritySearch {
*
* @param aSuiteName
* the suite name to open (or part of)
* @param aSelectFlag
* whether the suite name shall be jumped to and selected
* @return the opened editor or null
*/
IEditorPart openSuiteDefinitionByName(String aSuiteName);
IEditorPart openSuiteDefinitionByName(String aSuiteName, boolean aSelectFlag);

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ public Map convert(Object aSource, Class<? extends Map> aTargetType, ConversionC
try {
for (PropertyDescriptor tempDescriptor : Introspector.getBeanInfo(aSource.getClass(), Object.class)
.getPropertyDescriptors()) {

if (Boolean.TRUE.equals(tempDescriptor.getValue("transient"))) {
// Skip transient properties, as those are often used as "fake" properties in order to implement a
// getter for them which does some sort of magic. Calling unknown magical stuff in a generic fashion
// when running over Java Beans is not such a good idea and quickly leads to problems, which is the
// reason why transient properties are skipped here. See also issue #109.
continue;
}

Method tempReadMethod = tempDescriptor.getReadMethod();
if (tempReadMethod != null) {
Object tempValue = tempReadMethod.invoke(aSource);
Expand Down Expand Up @@ -83,4 +92,19 @@ public Map convert(Object aSource, Class<? extends Map> aTargetType, ConversionC

return tempKeyValueMap;
}

// protected boolean isTransient(String aFieldName, Class<?> aClass) {
// Class<?> tempClassInFocus = aClass;
// while(tempClassInFocus != null) {
// try {
// Field tempField = tempClassInFocus.getDeclaredField(aFieldName);
//
// if(tempField != null) {
// return tempField.getModifiers() & Modifier
// }
// } catch (NoSuchFieldException | SecurityException exc) {
// // ignore
// }
// }
// }
}
63 changes: 33 additions & 30 deletions de.gebit.integrity.tests/integrity/fixtures/BeanFixture.integrity
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
packagedef integrity.fixtures.basic.beans with

testdef checkSimpleBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#checkSimpleBean

testdef checkCollectionBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#checkCollectionBean

testdef alterPrimitiveBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#alterPrimitiveBean

testdef checkSimpleBeanUntyped uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#checkSimpleBeanUntyped

testdef createSimpleBeanUntyped uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createSimpleBeanUntyped
calldef createSimpleBeanUntypedCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createSimpleBeanUntyped

testdef createMapForSimpleBeanUntyped uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createMapForSimpleBeanUntyped
calldef createMapForSimpleBeanUntypedCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createMapForSimpleBeanUntyped

testdef echoEnumTestBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoEnumTestBean
calldef echoEnumTestBeanCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoEnumTestBean

testdef echoEnumValueFromTestBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoEnumValueFromTestBean
calldef echoEnumValueFromTestBeanCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoEnumValueFromTestBean

testdef echoMap uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoMap
calldef echoMapCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoMap

calldef createPrimitiveTypeArrayTestBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createPrimitiveTypeArrayTestBean

testdef createSimpleBeanUntypedEmpty uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createSimpleBeanUntypedEmpty
calldef createSimpleBeanUntypedEmptyCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createSimpleBeanUntypedEmpty

packagedef integrity.fixtures.basic.beans with

testdef checkSimpleBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#checkSimpleBean

testdef checkCollectionBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#checkCollectionBean

testdef alterPrimitiveBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#alterPrimitiveBean

testdef checkSimpleBeanUntyped uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#checkSimpleBeanUntyped

testdef createSimpleBeanUntyped uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createSimpleBeanUntyped
calldef createSimpleBeanUntypedCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createSimpleBeanUntyped

testdef createMapForSimpleBeanUntyped uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createMapForSimpleBeanUntyped
calldef createMapForSimpleBeanUntypedCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createMapForSimpleBeanUntyped

testdef echoEnumTestBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoEnumTestBean
calldef echoEnumTestBeanCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoEnumTestBean

testdef echoEnumValueFromTestBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoEnumValueFromTestBean
calldef echoEnumValueFromTestBeanCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoEnumValueFromTestBean

testdef echoMap uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoMap
calldef echoMapCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#echoMap

calldef createPrimitiveTypeArrayTestBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createPrimitiveTypeArrayTestBean

testdef createSimpleBeanUntypedEmpty uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createSimpleBeanUntypedEmpty
calldef createSimpleBeanUntypedEmptyCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createSimpleBeanUntypedEmpty

testdef createTransientTestBean uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createTransientTestBean
calldef createTransientTestBeanCall uses de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createTransientTestBean

packageend
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
packagedef integrity.basic.beans with

suitedef beanWithTransientProperty with

// This should succeed, since we don't check the transient property
test integrity.fixtures.basic.beans.createTransientTestBean = {
normalString: "foo"
}

// This should fail as we cannot see the transient property here since it's not converted to the map internally
test integrity.fixtures.basic.beans.createTransientTestBean = {
normalString: "foo"
transientString: "bar"
}

suiteend

packageend
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2013 Rene Schneider, GEBIT Solutions GmbH 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
*******************************************************************************/
package de.gebit.integrity.tests.junit.basic.beans;

import java.io.IOException;

import org.jdom.Document;
import org.jdom.JDOMException;
import org.junit.Test;

import de.gebit.integrity.runner.exceptions.ModelLoadException;
import de.gebit.integrity.tests.junit.IntegrityJUnitTest;

/**
* JUnit test which checks bean calls.
*
*
* @author Rene Schneider - initial API and implementation
*
*/
public class BeanWithTransientProperty extends IntegrityJUnitTest {

/**
* Performs a suite which does fixture calls with bean values and checks the resulting XML document.
*
* @throws ModelLoadException
* @throws IOException
* @throws JDOMException
*/
@Test
public void test() throws ModelLoadException, IOException, JDOMException {
Document tempResult = executeIntegritySuite(
new String[] { "integrity/suites/basic/beans/beanWithTransientProperty.integrity" },
"integrity.basic.beans.beanWithTransientProperty", null);
assertDocumentMatchesReference(tempResult);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<integrity name="Integrity JUnit Testing" timestamp="01.06.16 13:21" isotimestamp="2016-06-01T13:21:49" duration="27.521">
<variables />
<suite id="0" name="integrity.basic.beans.beanWithTransientProperty" timestamp="01.06.16 13:21:49.0238">
<setup />
<variables />
<statements>
<test id="1" line="6" name="createTransientTestBean" description="creates a transient test bean and returns it" fixture="de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createTransientTestBean" timestamp="01.06.16 13:21:49.0238">
<results duration="0.830" successCount="1" failureCount="0" exceptionCount="0">
<result duration="0.830" description="creates a transient test bean and returns it" type="success">
<parameters />
<comparisons>
<comparison expectedValue="[FORMATTED]{[NL][T]normalString = foo[NL]}" value="[FORMATTED]{[NL][T]normalString = foo[NL]}" type="success" />
</comparisons>
</result>
</results>
</test>
<test id="2" line="11" name="createTransientTestBean" description="creates a transient test bean and returns it" fixture="de.gebit.integrity.tests.fixtures.basic.beans.BeanFixture#createTransientTestBean" timestamp="01.06.16 13:21:49.0253">
<results duration="0.155" successCount="0" failureCount="1" exceptionCount="0">
<result duration="0.155" description="creates a transient test bean and returns it" type="failure">
<parameters />
<comparisons>
<comparison expectedValue="[FORMATTED]{[NL][T]normalString = foo[NL|, ][T][UL][B]transientString = bar[/B][/UL][NL]}" value="[FORMATTED]{[NL][T]normalString = foo[NL]}" type="failure" />
</comparisons>
</result>
</results>
</test>
</statements>
<returns />
<teardown />
<result duration="23.145" successCount="1" failureCount="1" exceptionCount="0" testExceptionCount="0" callExceptionCount="0" />
</suite>
</integrity>

Loading

0 comments on commit 136b2d9

Please sign in to comment.