Tuesday, September 1, 2015

jmockit AttachNotSupportedException:can't open socket java.lang.IllegalStateException: Invalid place to record expectations


-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Forking command line: /bin/sh -c cd /media/sf_srini/PG/code/VP/avatar-request-archiver/avrqar-consumer && /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85-2.6.1.2.el7_1.x86_64/jre/bin/java -jar /media/sf_srini/PG/code/VP/avatar-request-archiver/avrqar-consumer/target/surefire/surefirebooter2115359118106672711.jar /media/sf_srini/PG/code/VP/avatar-request-archiver/avrqar-consumer/target/surefire/surefire1753566432031656152tmp /media/sf_srini/PG/code/VP/avatar-request-archiver/avrqar-consumer/target/surefire/surefire_08062572582923452240tmp
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNGMapConfigurator@5123968
2015-09-02 09:06:01
Full thread dump OpenJDK 64-Bit Server VM (24.85-b03 mixed mode):
"Service Thread" daemon prio=10 tid=0x00007f4814174800 nid=0x1030 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
"C2 CompilerThread1" daemon prio=10 tid=0x00007f4814172000 nid=0x102f waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
"C2 CompilerThread0" daemon prio=10 tid=0x00007f481416f000 nid=0x102e waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
"Signal Dispatcher" daemon prio=10 tid=0x00007f481416d000 nid=0x102d waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
"Finalizer" daemon prio=10 tid=0x00007f4814142000 nid=0x102c in Object.wait() [0x00007f48067d7000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d8304800> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000007d8304800> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)
"Reference Handler" daemon prio=10 tid=0x00007f4814140000 nid=0x102b in Object.wait() [0x00007f48068d8000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007d8304418> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x00000007d8304418> (a java.lang.ref.Reference$Lock)
"main" prio=10 tid=0x00007f4814009000 nid=0x1025 waiting on condition [0x00007f481aa9b000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at sun.tools.attach.LinuxVirtualMachine.(LinuxVirtualMachine.java:100)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at mockit.internal.startup.AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(AgentLoader.java:69)
    at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:45)
    at mockit.internal.startup.Startup.verifyInitialization(Startup.java:172)
    at mockit.Invocations.(Invocations.java:26)
    at com.ihp.iwpp.avrqar.consumer.impl.KafkaRequestConsumerUnitTest.testRetriveMessages(KafkaRequestConsumerUnitTest.java:70)
    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:606)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:673)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:842)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1166)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.runWorkers(TestRunner.java:1178)
    at org.testng.TestRunner.privateRun(TestRunner.java:757)
    at org.testng.TestRunner.run(TestRunner.java:608)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1158)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1083)
    at org.testng.TestNG.run(TestNG.java:999)
    at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
    at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:159)
    at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:99)
    at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106)
    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:606)
    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:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
"VM Thread" prio=10 tid=0x00007f481413b800 nid=0x102a runnable
"GC task thread#0 (ParallelGC)" prio=10 tid=0x00007f481401f000 nid=0x1026 runnable
"GC task thread#1 (ParallelGC)" prio=10 tid=0x00007f4814021000 nid=0x1027 runnable
"GC task thread#2 (ParallelGC)" prio=10 tid=0x00007f4814022800 nid=0x1028 runnable
"GC task thread#3 (ParallelGC)" prio=10 tid=0x00007f4814024800 nid=0x1029 runnable
"VM Periodic Task Thread" prio=10 tid=0x00007f481417f000 nid=0x1031 waiting on condition
JNI global references: 192
Heap
 PSYoungGen      total 35840K, used 13714K [0x00000007d8300000, 0x00000007dab00000, 0x0000000800000000)
  eden space 30720K, 44% used [0x00000007d8300000,0x00000007d9064860,0x00000007da100000)
  from space 5120K, 0% used [0x00000007da600000,0x00000007da600000,0x00000007dab00000)
  to   space 5120K, 0% used [0x00000007da100000,0x00000007da100000,0x00000007da600000)
 ParOldGen       total 81408K, used 0K [0x0000000788a00000, 0x000000078d980000, 0x00000007d8300000)
  object space 81408K, 0% used [0x0000000788a00000,0x0000000788a00000,0x000000078d980000)
 PSPermGen       total 21504K, used 6251K [0x000000077e400000, 0x000000077f900000, 0x0000000788a00000)
  object space 21504K, 29% used [0x000000077e400000,0x000000077ea1afe0,0x000000077f900000)
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 6.826 sec <<< FAILURE!
testRetriveMessages(com.ihp.iwpp.avrqar.consumer.impl.KafkaRequestConsumerUnitTest)  Time elapsed: 5.37 sec  <<< FAILURE!
java.lang.ExceptionInInitializerError
    at com.ihp.iwpp.avrqar.consumer.impl.KafkaRequestConsumerUnitTest.testRetriveMessages(KafkaRequestConsumerUnitTest.java:70)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at mockit.internal.startup.AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(AgentLoader.java:73)
    at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:45)
    at mockit.internal.startup.Startup.verifyInitialization(Startup.java:172)
    at mockit.Invocations.(Invocations.java:26)
    ... 36 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at mockit.internal.startup.AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(AgentLoader.java:69)
    ... 39 more
Caused by: com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
    at sun.tools.attach.LinuxVirtualMachine.(LinuxVirtualMachine.java:106)
    ... 44 more


Results :

Failed tests:   testRetriveMessages(com.ihp.iwpp.avrqar.consumer.impl.KafkaRequestConsumerUnitTest)

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 13.821 s
Finished at: 2015-09-02T09:06:07+05:30
Final Memory: 26M/321M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project avrqar-consumer: There are test failures.


Solution:


                org.apache.maven.plugins
                maven-dependency-plugin
                2.5.1
               
                   
                        copy-agent
                        process-test-classes
                       
                            copy
                       

                       
                           
                               
                                    org.jmockit
                                    jmockit
                                    ${jmockit.version}
                                    ${project.build.directory}/agents
                                    jmockit.jar
                               

                           

                       

                   

               

           

           
                org.apache.maven.plugins
                maven-surefire-plugin
                ${maven.surefire.plugin.version}
               
                   
                        com/ihp/iwpp/avatar/exception/*.*
                   

                    -javaagent:${project.build.directory}/agents/jmockit.jar
               

           


Running com.ihp.iwpp.avrqar.consumer.impl.KafkaRequestConsumerUnitTest
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNGMapConfigurator@65447c32
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.114 sec <<< FAILURE!
testRetriveMessages(com.ihp.iwpp.avrqar.consumer.impl.KafkaRequestConsumerUnitTest)  Time elapsed: 0.063 sec  <<< FAILURE!
java.lang.IllegalStateException: Invalid place to record expectations
    at com.ihp.iwpp.avrqar.consumer.impl.KafkaRequestConsumerUnitTest$1.(KafkaRequestConsumerUnitTest.java:70)
    at com.ihp.iwpp.avrqar.consumer.impl.KafkaRequestConsumerUnitTest.testRetriveMessages(KafkaRequestConsumerUnitTest.java:70)


Results :

Failed tests:   testRetriveMessages(com.ihp.iwpp.avrqar.consumer.impl.KafkaRequestConsumerUnitTest): Invalid place to record expectations

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 6.189 s
Finished at: 2015-09-02T10:10:06+05:30
Final Memory: 16M/329M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-cli) on project avrqar-consumer: There are test failures. 


Solution:
This is a bug in older testng and jmockit versions. Using latest versions resolves this problem.

No comments:

Post a Comment

Followers