2

I'm having a problem with my test application which is follows. I'm having following code:

@Test(expected = InvalidStateException.class)
public void testLiianPitkaKayttajatunnus()

{...}

I'm using Eclipse and it says "InvalidStateException cannot be resolved to a type" and as we know if eclipse notice a problem it underline it with red wave line. I have been trying to search solutions but still not found any. I have tried following things but none of them has solved the problem:

  1. Adding org.apache.openjpa dependency to my pom.xml and adding line before class code "import org.apache.openjpa.persistence.InvalidStateException;"
  2. In thread, it is said that if you have in your class extension of other class, it should be taken out. This didn't helped neither.
  3. In the same thread one advice is to use JUnit 4.4 and it didn't helped neither.

So my question is how this problem can be solved?

For additional information, my class start follows (imports are not mentioned here) public class TietorakenneTest extends TietokantaTestCase {....} and JUnit version that I use is 4.10, any help is appreciated. If you need any other information about the code, please let me know and I will put them here.

Community
  • 1
  • 1
Amir
  • 1,031
  • 2
  • 19
  • 42
  • Just to make sure, you have not accidentally added the wrong exception? Maybe you intended to use the ordinary Java [IllegalStateException](http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalStateException.html)? – matsev Nov 13 '12 at 12:04

2 Answers2

0

Change your import statement to

org.apache.openjpa.util.InvalidStateException and as you mentioned add org.apache.openjpa dependency to my pom.xml

Hope it helps.

Sajan Chandran
  • 11,287
  • 3
  • 29
  • 38
0

Qualify the class by adding the package name.

@Test(expected = org.apache.openjpa.persistence.InvalidStateException.class)
Roman C
  • 49,761
  • 33
  • 66
  • 176
  • Thanks, now it works. I used that method @Test(expected = org.apache.openjpa.persistence.InvalidStateException.class), imported org.apache.openjpa.persistence.InvalidStateException and also added following dependency on my pom.xml file: org.apache.openjpa openjpa-persistence 2.2.0 – Amir Nov 13 '12 at 12:08
  • If you satisfied with the answer better accept it to help us support you further and improve your rating. – Roman C Nov 13 '12 at 12:22