I'm encrypting data using Kaffe JVM (equivalent to java 1.1) and trying decrypting data with JDK7.
In my algorithm I use BigInteger (RSA encription). When I tested the application in JDK, all its OK, but when I trying to deserialize with JDK7 from a generated BigIntegers in Kaffe JVM I get this Exception listed below.
I was thinking in many causes of problem:
Different JVMs: http://www-01.ibm.com/support/docview.wss?uid=swg1IV13214
Problem with Big Endians and little endians
problem with processor type (16-bits, 32 -bits 64-bits).
Any ideas how to fix or detect the cause of the problem?
Thanks in advance.
java.io.StreamCorruptedException: BigInteger: signum-magnitude mismatch
at java.math.BigInteger.readObject(BigInteger.java:3113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1866)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1685)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1341)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1964)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1888)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at commons.persistence.PersisterDataBigIntegerBuffer.fileToObjects(PersisterDataBigIntegerBuffer.java:87)
at commons.persistence.CryptoRSAFileManager.getDataFromFile(CryptoRSAFileManager.java:44)
at test.commons.csv.ParserTester.test(ParserTester.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
It looks like a difference in serialization formats.
To solve this problem you are probably going to have to subclass BigInteger and override the readObject method once you figure out the storage format from the source JDK. To give you a hint on what you're in for, here is the relavant part of BigInteger's readObject from OpenJDK:
// Read the alternate persistent fields that we care about
int sign = fields.get("signum", -2);
byte[] magnitude = (byte[])fields.get("magnitude", null);
// Validate signum
if (sign < -1 || sign > 1) {
String message = "BigInteger: Invalid signum value";
if (fields.defaulted("signum"))
message = "BigInteger: Signum not present in stream";
throw new java.io.StreamCorruptedException(message);
}
Related
I have VAST XML and validating it against vast 2.0.1 xsd. It throws following error:-
Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'VAST'
My VAST XML:-
<VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0"
xsi:noNamespaceSchemaLocation="vast.xsd">
<Ad id="11267375">
<InLine>
<AdSystem version="1.0">Sample vast</AdSystem>
<AdTitle><![CDATA[AD_NFM3122HD.mov]]></AdTitle>
<Description><![CDATA[<p> </p>]]></Description>
<Creatives>
<Creative sequence="1" AdID="" id="11267375">
<Linear>
<Duration>00:00:15</Duration>
</Linear>
</Creative>
</Creatives>
</InLine>
</Ad>
</VAST>
VAST 2.0.1.xsd - https://github.com/chrisdinn/vast/blob/master/lib/vast_2.0.1.xsd
When I remove xsi:noNamespaceSchemaLocation="vast.xsd"> from my VAST Xml. Its working well.
Should I need to use this xsi:noNamespaceSchemaLocation="vast.xsd"> definitely. What is the use of it ?
What is the XSD filename I have to use in it instead of "vast.xsd" ?
I am running on java 1.8 and here is my stack trace
org.xml.sax.SAXParseException; cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'VAST'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:452)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3230)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(XMLSchemaValidator.java:2707)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2050)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:740)
at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.beginNode(DOMValidatorHelper.java:277)
at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:244)
at com.sun.org.apache.xerces.internal.jaxp.validation.DOMValidatorHelper.validate(DOMValidatorHelper.java:190)
at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:109)
at javax.xml.validation.Validator.validate(Validator.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.rules.Verifier$1.evaluate(Verifier.java:35)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:62)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Here is your XML repaired to be valid against the vast.xsd, which I've referenced remotely:
<VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/chrisdinn/vast/master/lib/vast_2.0.1.xsd">
<Ad id="11267375">
<InLine>
<AdSystem version="1.0">Sample vast</AdSystem>
<AdTitle><![CDATA[AD_NFM3122HD.mov]]></AdTitle>
<Description><![CDATA[<p> </p>]]></Description>
<Survey/>
<Error/>
<Impression/>
<Creatives>
<Creative sequence="1" AdID="" id="11267375">
<Linear>
<Duration>00:00:15</Duration>
</Linear>
</Creative>
</Creatives>
</InLine>
</Ad>
</VAST>
I've added some elements required by the XSD, however even without such additions, you should not have been receiving an error complaining that
Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element 'VAST'
If you still receive that error with the above XML, please post a comment stating the software from which the error is originating.
Update: Still not working?
If you are specifying the location of the XSD in your Java code,
Schema schema = schemaFactory.newSchema(new URL(getSchemaURLString()));
but you wish to use xsi:noNamespaceSchemaLocation instead, try removing the Java-based specification of the XSD location:
Schema schema = schemaFactory.newSchema();
This happened to me once because in the
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
part I had written http// instead of http://. Which suggests that the error was thrown when the validator couldn't find the namespace you I was referring to and was therefore be unable to validate the xsi:noNamespaceSchemaLocation attribute (since it's also in xsi).
If the namespace url is correct (and it does look correct in your xml) then it might suggest that it's the version that it can't find.
I would perhaps remove the version attribute (I don't know if there is a version 2.0), confirm that the version number is correct or use xsi:version as possible things to try if I were in this situation.
I'm currently trying to press the F5 keybinding using SWTBot tests to refresh a project in the package explorer. So far, I have been unsuccessful.
When I attempt to press the F5 keybinding in a way such as this:
SWTBotView packageExplorer = getPackageExplorer();
SWTBotTree tree = packageExplorer.bot().tree();
SWTBotTreeItem treeItem = tree.getTreeItem("newProject");
treeItem.select();
treeItem.pressShortcut(0, SWT.F5, (char) 0);
I receive the following stack trace:
java.lang.ExceptionInInitializerError
at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.pressShortcut(Keyboard.java:138)
at org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot.pressShortcut(AbstractSWTBot.java:862)
at org.eclipse.project.ui.wizard.project.RefreshUiTest.performDefaultEclipseRefresh(RefreshUiTest.java:43)
at org.eclipse.project.ui.wizard.project.RefreshUiTest.defaultEclipseBehaviourIsNotHindered(RefreshUiTest.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner.run(SWTBotJunit4ClassRunner.java:54)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness$1.run(PlatformUITestHarness.java:47)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3717)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3366)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.runApp(NonUIThreadTestApplication.java:54)
at org.eclipse.pde.internal.junit.runtime.UITestApplication.runApp(UITestApplication.java:47)
at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:48)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.IllegalArgumentException: EN_CA.keyboard not found, see http://wiki.eclipse.org/SWTBot/Keyboard_Layouts for more information.
at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.getKeyboardLayout(KeyboardLayout.java:89)
at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.getDefaultKeyboardLayout(KeyboardLayout.java:75)
at org.eclipse.swtbot.swt.finder.keyboard.Keystrokes.<clinit>(Keystrokes.java:110)
... 61 more
I've also tried using:
Keyboard key = KeyboardFactory.getSWTKeyboard();
key.pressShortcut(Keystrokes.F5);
but it has failed with a nearly identical stacktrace.
How can I simulate pressing the F5 key on a project in the package explorer using SWTBot tests?
The root cause indicates that EN_CA.keyboard not found. SWTBot does not come with a predefined EN_CA keyboard layout.
If it fits your needs you can use the EN_US keyboard layout like this
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
Or define your own keyboard layout as desribed here: https://wiki.eclipse.org/SWTBot/Keyboard_Layouts
I am using the SWTBot recorder to test a very simple feature. I just want to create a Dynamic Web Project and then delete it. But it won't even create the project. Why is it blowing up here?
Here is the code that the recorder generated:
#RunWith(SWTBotJunit4ClassRunner.class)
public class TestSwtBot {
private static SWTWorkbenchBot bot = new SWTWorkbenchBot();
#Test
public void test() {
bot.menu("File").menu("New").menu("Other...").click();
bot.tree().getTreeItem("Web").getNode("Dynamic Web Project").select();
bot.textWithLabel("Project na&me:").setText("TestDynamicProject");
bot.button("Next >").click();
bot.button("Next >").click();
bot.checkBox("Generate web.xml deployment descriptor").click();
bot.button("Finish").click();
bot.button("No").click();
bot.checkBox("Delete project contents on disk (cannot be undone)").click();
bot.button("OK").click();
}
So it is blowing up on this line:
bot.tree().getTreeItem("Web").getNode("Dynamic Web Project").select();
And here is the stacktrace:
org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could not find node with text: Dynamic Web Project
at org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem.getNodes(SWTBotTreeItem.java:338)
at org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem.getNode(SWTBotTreeItem.java:312)
at org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem.getNode(SWTBotTreeItem.java:350)
at com.homedepot.is.dt.eclipse.swtbot.TestSwtBot.test(TestSwtBot.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner.run(SWTBotJunit4ClassRunner.java:54)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main(RemotePluginTestRunner.java:64)
at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(UITestApplication.java:117)
at org.eclipse.e4.ui.internal.workbench.swt.E4Testable$1.run(E4Testable.java:73)
at java.lang.Thread.run(Thread.java:745)
You need to expand the "Web" tree item first.
bot.tree().getTreeItem("Web").expand();
bot.tree().getTreeItem("Web").getNode("Dynamic Web Project").select();
did you use Eclipse Spy to see if your calling the correct tree?, I mean, in this part of your code: bot.tree() you can call differents trees by their index, for example bot.tree(0) or bot.tree(1) maybe is looking for your node in another tree.
For more information about Eclipse spy, please see here: https://wiki.eclipse.org/SWTBot/FAQ#Can_I_get_more_details_on_a_particular_widget.3F
select with where clause works fine in cassandra cqlsh> but not from Astyanax. However, SLQ clause without where clause works fine from astyanax. Not sure what I'm missing any thoughts?
CREATE TABLE personalization1 (
username text primary key,
incidentPage text,
timelinePage text,
);
insert into personalization1 (username,incidentpage,timelinepage) values ('3cd70b90-d211-11e3-8774-14109fdb7013','3cd70b90-d211-11e3-8774-14109fdb7013','3cd70b90-d211-11e3-8774-14109fdb7013');
SELECT * FROM personalization1 where username='3cd70b90-d211-11e3-8774-14109fdb7013' ;
com.netflix.astyanax.connectionpool.exceptions.BadRequestException: BadRequestException: [host=10.65.240.89(10.65.240.89):9160, latency=237(342), attempts=1]InvalidRequestException(why:No indexed columns present in by-columns clause with "equals" operator)
at com.netflix.astyanax.thrift.ThriftConverter.ToConnectionPoolException(ThriftConverter.java:159)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:65)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:28)
at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$ThriftConnection.execute(ThriftSyncConnectionFactoryImpl.java:151)
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:119)
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:338)
at com.netflix.astyanax.thrift.AbstractThriftCqlQuery.execute(AbstractThriftCqlQuery.java:41)
at com.ebay.timeline.dao.PersonaliztionDAOTest.test(PersonaliztionDAOTest.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: InvalidRequestException(why:No indexed columns present in by-columns clause with "equals" operator)
at org.apache.cassandra.thrift.Cassandra$execute_cql_query_result.read(Cassandra.java:36625)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_execute_cql_query(Cassandra.java:1525)
at org.apache.cassandra.thrift.Cassandra$Client.execute_cql_query(Cassandra.java:1511)
at com.netflix.astyanax.thrift.ThriftCqlQuery.execute_cql_query(ThriftCqlQuery.java:33)
at com.netflix.astyanax.thrift.AbstractThriftCqlQuery$1.internalExecute(AbstractThriftCqlQuery.java:46)
at com.netflix.astyanax.thrift.AbstractThriftCqlQuery$1.internalExecute(AbstractThriftCqlQuery.java:43)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:60)
I notice from the stack trace that the "execute_cql_query" function is being used, not "execute_cql3_query", so the query being run is being run like it was executed in cqlsh -2, that is most likely the issue. The name of the primary key from cql2's view of things is probably "key".
I am new to Mockito, I am using it along with JUnit4 in Eclipse.
I am trying to mock my method as follows:
CartLine line = mock(CartLine.class);
Then I get: FileNotFoundException caused by the call of the supposedly mocked method, as shown in the stacktrace below. How is this the expected behaviour? I am using Mockito precisely to avoid using the whole environment.
Stack Trace:
java.io.FileNotFoundException: cart.properties (file not found)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at com.mycompany.cart.util.ResourceFactory.getFileInputStream(ResourceFactory.java:119)
at com.mycompany.cart.util.ResourceFactory.getProperties(ResourceFactory.java:295)
at com.mycompany.cart.CartSettings.tryLoadSettings(CartSettings.java:215)
at com.mycompany.cart.CartSettings.<init>(CartSettings.java:72)
at com.mycompany.cart.CartSettings.<clinit>(CartSettings.java:60)
at com.mycompany.cart.CartLine.<clinit>(CartLine.java:59)
at sun.reflect.GeneratedSerializationConstructorAccessor4.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:40)
at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:59)
at org.mockito.internal.creation.jmock.ClassImposterizer.createProxy(ClassImposterizer.java:128)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:63)
at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:56)
at org.mockito.internal.creation.CglibMockMaker.createMock(CglibMockMaker.java:23)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:26)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:51)
at org.mockito.Mockito.mock(Mockito.java:1243)
at org.mockito.Mockito.mock(Mockito.java:1120)
at com.redacted.ml.TestConfToJasper.mockCartLine(TestConfToJasper.java:173)
at com.redacted.ml.TestConfToJasper.mockCartLines(TestConfToJasper.java:131)
at com.redacted.ml.TestConfToJasper.testBuildUCSElement(TestConfToJasper.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
1249 [main] WARN com.redacted.cart.util.ResourceFactory - Can not find property file: cart.properties
1249 [main] FATAL com.redacted.cart.CartSettings - Can not load cart properties!
Edit: Here is the full test code:
private static final CartLine mockCartLine(LineType type) {
CartLine line = mock(CartLine.class);
when(line.getLineType()).thenReturn(type);
return line;
}
called by:
private static final CartLine[] mockCartLines() {
CartLine[] lines = new CartLine[10];
int i=0;
lines[i++] = mockCartLine(LineType.FO);
[...]
return lines;
}
called by:
#Test
public void testBuildUCSElement() {
ConfToJasper ctj = new ConfToJasper(confML);
CartController controller = mock(CartController.class);
CartDataObject dataObject = mock(CartDataObject.class);
CartLine[] lines = mockCartLines();
[...]
}
(I am not the creator of this code)
it seems to me that you have some kind of static initializer in your CartLine which tried to open file stream.
I will strong suggest you cleanup your code to make it unit-test friendly by removing such kind of static initializer logic. (It is usually more appropriate to make it instance method instead)
Or you may have a dummy `cart.properties1 in your testing resources so that your CartLine can read that.
Or you may consider using PowerMock to see if it help to avoid such problem (I doubt anyway...)