I writing tests for my DAO classes using JPA, with Hibernate as JPA provider, and Spring 3.2. I am not able to inject the entity manager correctly, I get a NullPointerException when trying to access it. My GenericDAO implementation looks like this: The class of the test looks like this: My root-context.xml is…
Tag: java
JUnit Tests for GUI in Java
I would like to write test cases for a GUI. I want to know how do you simulate a click of JButton, or how do you extract the elements of a JTable. For the purpose of this, I have built a simple GUI that increase the count by 1 if the button is clicked and the JTextfield is empty, but
Glassfish unable to deploy at root because default-web-module is declared
While trying to deploy to Glassfish Server Open Source Edition 3.1.2.2 (build 5) from both Netbeans and Admin Console the following message is thrown. Eventhough the Applications section of the Admin Console has no deployed applications. I have tried restarting the domain without success. Exception while load…
How to use named parameter in plain sql with jooq
I’m using JOOQ with plain/raw SQL, so that means i’m not using any code generation or the fluid DSL thingy. The following code works: Now let’s say i have a query with multiple parameters like this: How do i use a named parameter with these types of queries? I’m thinking something like…
Switch listener in ListView giving wrong results
Here is my Array adapter. It assigns each switch button in the list with a listener that is dependant on the id given by the database (passed using devices.id). But for some reason, the switch listener is getting the correct states from the switches. For debugging purpose, I’m just using the same on cha…
BasicFileAttributes vs BasicFileAttributeView in Java
What is the difference between these two interfaces? BasicFileAttributes vs BasicFileAttributeView I understand that they serve to retrieve basic metadata from a file, but what actually differs from each other? EDIT: I previously meant that in the following example the 2 interfaces are used interchangeably. I…
Resize a picture to fit a JLabel
I’m trying to make a picture fit a JLabel. I wish to reduce the picture dimensions to something more appropriate for my Swing JPanel. I tried with setPreferredSize but it doesn’t work. I’m wondering if there is a simple way to do it? Should I scale the image for this purpose? Answer Outline …
ApplicationInfo metadata returning null
I have the following code: In the manifest: In the code: But the result is ai.metaData==null. Why is this happening Answer From the latest android doc, <meta-data> can be only contained in <activity>/<activity-alias>/<service>/ <receiver>. So you should append meta-data in these …
Eclipse plugin dev, how to stop HttpsURLConnection of poping up user/password window when I connect
JDK IBM 1.6 Eclipse 3.6.2 Connect to a server with following code. URL urlTemplate = new URL(uri); uc = (HttpURLConnection) urlTemplate.openConnection(); when connecting with wrong credential, it will pop up a window to enter correct credential as input, how to stop it? it seems to be built-in action and unab…
Getting JTextArea to display fixed-width font without antialiasing
Does anybody know how to get JTextArea to display a fixed size font on all platforms? I want to make a simple code editor with save/open functionality, which is simple enough, but I would like to get font to be fixed-size, preferably courier new. The problem is that courier new is proprietary apparently, and …