I am running into an unexpected issue with one of my scripts.
I have a an application that can publish news on a number of different levels such as an organisational level and levels lower down in the organisation. Depending on your occupation only certain people can publish a news article on the org level.
I have written the scripts on this level and they all work.
I copied the scripts and slightly modified them to publish the news at a lower level and this is where I am seemingly running into trouble. One particular script adds an image into the news article and to do that you need to manipulate a series of modal dialog windows. This workflow is identical to the org level.
However when I run the script at the lower level I get an error which states:
java.lang.ArrayIndexOutOfBoundsException: 1
The stacktrace is as follows:
at com.desire2learn.dev.pages.CreateItemNewsPage.get_window_ids(CreateItemNewsPage.java:338)
at com.desire2learn.dev.tests.NewsItemsUnitLevelTest.publish_news_with_image(NewsItemsUnitLevelTest.java:379)
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:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
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:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
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:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
The code it slips up on is the following:
public void get_window_ids(){
//Get the handles for the main window and the popup window for the upload button
try {
Set<String> AllWindowHandles = driver.getWindowHandles();
System.out.println(AllWindowHandles.size()+ " distinct windows: " + AllWindowHandles);
window1 = (String) AllWindowHandles.toArray()[0];
System.out.println("\nwindow 1 is " + window1+"\n");
window2 = (String) AllWindowHandles.toArray()[1];
System.out.println("\nwindow 2 is " + window2+"\n");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
It trips up on window2.
However this same method works on the org level. I also notice that it says there are 2 distinct windows at org level:
2 distinct windows: [CDwindow-13376ec5-43ac-4668-a2f9-50660e3b09cf,
CDwindow-d3e9e6eb-954a-4bf8-ba28-b30049ed85d8]
Also when I debug on the unit level iget the following:
2 distinct windows: [CDwindow-13376ec5-43ac-4668-a2f9-50660e3b09cf,
CDwindow-d3e9e6eb-954a-4bf8-ba28-b30049ed85d8]
Running the script I get only 1 distinct window however....very strange.
It baffles me. Can someone give me a pointer or am I just doing something stupid here?
UPDATE
I changed a configuration setting in the application which controls whether popups are displayed as modal or nonmodal popups and it seems to resolve the issue. The popup still displays that it is nonModalDialog however. So it appears that nothing has changed. Except the script does not work when the conf item is disabled and works when it is disabled.
Please disregard this question I have resolved it. The issue was with Modal and non modal windows and my script was configured for nonmodal popups. I couldnt see that the scripts I ran in a different part of the application had beed configured for modal dialogs breaking my script in the process.
Appologies for wasting peoples time on this.
Related
Executing the following results in the exception "Cannot invoke a rollback operation when the AutoCommit mode is set to "true".
java.sql.Connection connection = DriverManager.getConnection(connectionString);
com.ibatis.common.jdbc.ScriptRunner scriptRunner = new ScriptRunner(connection, true, true);
java.io.StringReader reader = new StringReader("PRINT 1;");
scriptRunner.runScript(reader);
// Cannot invoke a rollback operation when the AutoCommit mode is set to "true".
There is no rollback referenced in my code, and I can find no option to disable it from being forced on me. I have looked through standalone.xml and tried setting jta=false. I found and set commitRequired=false, it was true, on sqlMapConfig\transactionManager, but that did not make a difference.
If the answer to this exists out there, I was not able to find it. All I find is someone saying "of course you cant rollback", and the result being to disable autocommit. I am not asking for a rollback, so where is it coming from?
Per https://www.programcreek.com/java-api-examples/index.php?api=com.ibatis.common.jdbc.ScriptRunner example 3, what I am doing should work.
I want to execute a script in autocommit mode (the default MS SQL Server mode) without any transactions being involved or forced on me, except the autocommit transaction that surrounds each individual statement in the sql script. I do not want IMPLICIT_TRANSACTIONS ON, no BEGIN TRANSACTION, no COMMIT, and definitely no ROLLBACK.
Thank you for your time
Stack Trace:
com.microsoft.sqlserver.jdbc.SQLServerException: Cannot invoke a rollback operation when the AutoCommit mode is set to "true".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:191)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.rollback(SQLServerConnection.java:2037)
at com.ibatis.common.jdbc.ScriptRunner.runScript(ScriptRunner.java:222)
at com.ibatis.common.jdbc.ScriptRunner.runScript(ScriptRunner.java:114)
at com.metric.DebugTests.DebugAutoCommit(DebugTests.java:32)
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:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
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:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
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:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Based on a quick glance at ScriptRunner (not the exact version in the question, but close enough), we can see the following code
if (!autoCommit) {
conn.commit();
}
Now that's good, we only commit if autocommit isn't on. However, if an exception is thrown, the finally clause is executed and autocommit isn't considered:
} finally {
conn.rollback();
flush();
}
This will result in the losing of the original exception details.
Since the exception does print logs if a logger is set, I recommend doing something like:
scriptRunner.setErrorLogWriter(somePrintWriter); // Some PrintWriter, maybe to a file
That way you'll find out the original exception. This is also definitely a bug, so it needs to be reported (seems I don't have github credentials, so someone that has those could put up an issue (or hey, why not submit a pull request)).
If you are setting auto commit off then you are responsible for saving you work on database so after every successful task you have to execute a commit command,
To set autocommit off use connection.setAutoCommit(false)
and when your work is finished then execute
connection.commit() to save changes to database
or in case of any error execute a rollback command connection.rollback()
Hope It Hepls !!
I'm writing a piece of dataflow transform that uses org.apache.beam.sdk.state.MapState to implement caching functionality. However upon introducing MapState, the unit test starts to dysfunction. The exception says: java.lang.UnsupportedOperationException: Parameter StateParameter{referent=StateDeclaration{id=cache, field=private final org.apache.beam.sdk.state.StateSpec xxxxFn.cache, stateType=org.apache.beam.sdk.state.MapState<java.lang.String, object>}} not supported by DoFnTester
So if DoFnTester is no longer an option, what is the current best practice for testing a DoFn that use MapState?
P.S. I'm currently on Beam 2.0.0, and I can't upgrade to 2.2.0 because https://issues.apache.org/jira/browse/BEAM-3693
Here is the complete Trace:
java.lang.UnsupportedOperationException: Parameter StateParameter{referent=StateDeclaration{id=cache, field=private final org.apache.beam.sdk.state.StateSpec xxxxFn.cache, stateType=org.apache.beam.sdk.state.MapState<java.lang.String, object>}} not supported by DoFnTester
at org.apache.beam.sdk.transforms.DoFnTester$5.dispatchDefault(DoFnTester.java:725)
at org.apache.beam.sdk.transforms.DoFnTester$5.dispatchDefault(DoFnTester.java:710)
at org.apache.beam.sdk.transforms.reflect.DoFnSignature$Parameter$Cases$WithDefault.dispatch(DoFnSignature.java:255)
at org.apache.beam.sdk.transforms.reflect.DoFnSignature$Parameter.match(DoFnSignature.java:193)
at org.apache.beam.sdk.transforms.DoFnTester.<init>(DoFnTester.java:709)
at org.apache.beam.sdk.transforms.DoFnTester.of(DoFnTester.java:92)
at xxxxFnTest.testNormalRun(GetPredictionsFnTest.java:50)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
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:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
The Java DirectRunner is the best way to test your DoFn, whatever features it uses.
Using DoFnTester will enable you to gain false confidence by testing scenarios that are not feasible while missing scenarios that can really happen. For this reason, and bugs / lack of maintenance, DoFnTester is now deprecated and you should try to move off of it.
To have control over watermarks, the processing clock, and element bundling, you can use TestStream as described on the Beam blog.
I`m getting
android.support.test.espresso.PerformException: Error performing 'send
keyCode: 4, metaState: 0 key event' on view 'Animations or transitions
are enabled on the target device.
I read articles with same error but didnt find answer.
I have simple android app and I try to test simple thing:
Load RecyclerView
Click on RecyclerView`s item
Open Activity
Press button inside Activity
Press back
Repeat from part 1.
Code is extremely easy:
#Test
public void getOver500Products() {
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
onView(withId(R.id.layout2)).perform(click());
clickExactItem(2);
for (int i = 0; i< 501; i++) {
clickRandomItem();
addedToCart();
Espresso.pressBack();
}
}
public void clickRandomItem() {
try {
int x = getRandomRecyclerPosition(R.id.list);
clickExactItem(x);
} catch (NoMatchingViewException e) {
}
}
public void clickExactItem(int position) {
onView(withId(R.id.list))
.perform(RecyclerViewActions
.actionOnItemAtPosition(position, click()));
}
public boolean addedToCart() {
try {
onView(withId(R.id.product_add_in_cart)).perform(click());
} catch (NoMatchingViewException e) {
return false;
}
return true;
}
It throws exception after 10-50 iterations (randomly) so basically code is right.
EspressoTestDev.java:88 line where it crashes is
Espresso.pressBack();
Exactly after this line I`m getting exception.
Exception stacktrace:
android.support.test.espresso.PerformException: Error performing 'send keyCode: 4, metaState: 0 key event' on view 'Animations or transitions are enabled on the target device.
is a root view.'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:80)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:56)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
at android.support.test.espresso.Espresso.pressBack(Espresso.java:189)
at com.app.myapp.EspressoTestDev.getOver500Products(EspressoTestDev.java:88)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:270)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1851)
Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints:
is displayed on the screen to the user
Target view: "PopupViewContainer{id=-1, visibility=VISIBLE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}"
at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:138)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5549)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Looks like it found problem with PopupViewContainer but I dont use it, dont click it and I have no idea how can it impact to Espresso.pressBack()
What I tried:
Adding getInstrumentation().waitForIdleSync(); before and after Espresso.pressBack()
Making delay as suggested here
The question is: how can I avoid this error or how can I ignore and continue iterations in my case?
Animations or transitions are enabled on the target device.
Espresso doesn't work well with animations due to the visual state delays they introduce. You need to disable animations on your device. Firstly, enable developer options:
Open the Settings app.
Scroll to the bottom and select About phone.
Scroll to the bottom and tap Build number 7 times.
Return to the previous screen to find Developer options near the bottom.
Access Developer Options from Settings app, and under the Drawing section, switch all of the following options to Animation Off:
Window animation scale
Transition animation scale
Animator duration scale
In addition to the accepted answer, if you want to open the emulator from console, you have to add the following commands:
- adb shell settings put global window_animation_scale 0 &
- adb shell settings put global transition_animation_scale 0 &
- adb shell settings put global animator_duration_scale 0 &
In my case, Espresso gave me the "Animations or transitions are not enabled..." error, but that wasn't actually the root cause.
Scrolling through the stack trace I found this:
androidx.test.espresso.PerformException: Error performing 'scroll to' on view 'Animations or transitions are enabled on the target device.
...
Caused by: java.lang.RuntimeException:
Action will not be performed because the target view does not match one or more
of the following constraints:
(view has effective visibility=VISIBLE and is descendant of a: (
is assignable from class: class android.widget.ScrollView or
is assignable from class: class android.widget.HorizontalScrollView or
is assignable from class: class android.widget.ListView
))
Target view: "LinearLayout{...}"
That is, I was trying to scroll something that can't be scrolled.
So, always read through the stacktrace folks 👌
ensure the control you want to work with is visible. this worked for me. add "scrollTo()"
onView(...).perform(scrollTo(), click());
I've run into the error Animations or transitions are enabled on the target device several times. In the latest case, the real problem was that my UI code was throwing a NullPointerException. Unfortunately Espresso was "swallowing" the NullPointerException and giving me the irrelevant error Animations or transitions are enabled on the target device.
I had a similar error but after inspecting the logcat, I realised the fragment under test was trying to do a navigation and the nav graph wasn't defined in the test because the fragment had been launched with launchFragmentInContainer. Fixing that fixed the issue.
Before clicking item on specific position, should be scroll that position,
onView(withId(R.id.list))
.perform(RecyclerViewActions
.scrollToPosition(position));
onView(withId(R.id.list))
.perform(RecyclerViewActions
.actionOnItemAtPosition(position, click()));
A simple try catch.
Where you only pick up the exception if it is an PerformException.
Alternativ add the 500 items to your shopping cart by code, and then add 1 extra by UI test.
I am working on a Java RMI project and I am trying to begin to test the code I've written and when I run the following code, I get an AssertionError on a line that doesn't even have an assertion statement. I am confused as to how to fix this.
public void basicTest() throws UnknownHostException, RemoteException, AlreadyBoundException, NotBoundException, InterruptedException {
int numBooks = 20;
int copiesPerBook = 5;
int booksPerMember = 4;
// Simulate the server
LibraryServerImpl library = new LibraryServerImpl(numBooks, copiesPerBook, booksPerMember);
LibraryServer stub = (LibraryServer) java.rmi.server.UnicastRemoteObject.exportObject(library, 0);
Registry registry = LocateRegistry.createRegistry(port);
registry.bind(libraryName, stub);
// Simulate the client
Member member = new MemberImpl();
assertNotNull(member.getName()); // Will fail until you implement MemberImpl
Thread t = new Thread(new BasicClient(member));
t.start();
t.join();
}
This is the copied trace:
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertNotNull(Assert.java:712)
at org.junit.Assert.assertNotNull(Assert.java:722)
at PublicTests.basicTest(PublicTests.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
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.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Line 56 corresponds to registry.bind(libraryName, stub);
Clearly, this does not make sense, so one of the facts is false.
Fact: you got the above stack trace. --no reason to doubt the truthfulness of this fact.
Fact: PublicTests.java is written by you. --no reason to doubt the truthfulness of this fact.
Fact: line 56 of PublicTests.java corresponds to registry.bind(libraryName, stub). Well, this cannot be true, since according to the stack trace, the failure is detected by a call to org.junit.Assert.assertNotNull(), but the line registry.bind(libraryName, stub) is not an invocation of org.junit.Assert.assertNotNull().
However, further down in your code you do have an invocation of assertNotNull(member.getName()), which means that this must be what is being reported as line 56.
So, what you are looking at is a mismatch in the line number being reported in the stack trace. As user indivisible suggested, please refresh your project, clean your output folder, rebuild all projects, and try again.
We are calling the API to undeploy vApps, during out of hours periods, only to start them up again afterwards.
I get an intermittent error whilst trying to undeploy VApps. (I will give the full stack trace later).
Just to let you know what I am doing, is that I am calling VApp.shutdown() first, which always seems to return success. I sometimes wait a period of upto 10 minutes, before calling the Vapp.undeploy(UndeployPowerActionType.DEFAULT) call. It still more often than not, doesnt work. When I then run it again, it quite often DOES work (and when I check the result, the Vapp is indeed undeployed), or if it still doesn't work, then when I call it again, it does work.
The stack trace looks like the following.. (sometimes the array index is out of range with different numbers, eg -5 or -12 etc etc. Bu the stack trace always looks like the following...)
2014-07-17 13:10:33 ERROR [main] ControlModule:75 - Undeploying resulted in an error
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -2
at com.sun.xml.bind.v2.util.CollisionCheckStack.findDuplicate(CollisionCheckStack.java:133)
at com.sun.xml.bind.v2.util.CollisionCheckStack.push(CollisionCheckStack.java:71)
at com.sun.xml.bind.v2.runtime.XMLSerializer.pushObject(XMLSerializer.java:494)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:609)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:113)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:120)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:149)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:269)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:276)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:35)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:472)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:301)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:230)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:106)
at com.vmware.vcloud.sdk.JAXBUtil.marshal(JAXBUtil.java:199)
at com.vmware.vcloud.sdk.AbstractVapp.createVappUnDeployParamBody(AbstractVapp.java:299)
at com.vmware.vcloud.sdk.AbstractVapp.undeploy(AbstractVapp.java:318)
at com.ipt.ebsa.skyscape.client.module.ControlModule.controlVApp(ControlModule.java:70)
at com.ipt.ebsa.skyscape.client.manager.VMManager.controlVApp(VMManager.java:294)
at com.ipt.ebsa.skyscape.client.CloudManager.UndeployVApp(CloudManager.java:197)
at com.ipt.ebsa.skyscape.client.RajVAppTest.stopAndUndeployVApp(RajVAppTest.java:178)
at com.ipt.ebsa.skyscape.client.RajVAppTest.testUndeployVApp0(RajVAppTest.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:94)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:619)
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.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)
2014-07-17 13:10:33 DEBUG [main] ControlModule:77 - Undeploying of vapp 'TEST_RAJ2' complete
2014-07-17 13:10:33 DEBUG [main] VMManager:296 - controlVApp exit
Can someone tell me if I am doing anything wrong? Is it normal practise to just have to retry, and eventually it will work, in order to undeploy my Vapp.
If that is the case, and I do have to keep retrying, I can detect this exception, and if I get it, rety a certain number of times before failing finally and giving up?
Or is there another way to detect whether the Vapp is undeployed or not?
Would calling 'shutdown() rather than undeploy() work better? I think , in my experience, that seems more consistent. However, the resulting vApps in the console are entitled as 'partially running' rather than 'shutdown'. This may well be acceptable, as at the end of the day, we just want our cloud hosting partner to stop charging us for periods when we are not needing the vAPPs. I think shutting down the vAPP might actually achieve this purpose? I would have to check iwth the cloud hosting partner.
Any help is much appreciated.
Thanks,