How to test "add" in DAO without using "find" etc.?

In following code the issue is, that I cannot test dao.add() without using dao.list().size() and vice versa. Is this approach normal or incorrect? If incorrect, how can it be improved? public class ItemDaoTest { // dao to test @Autowired private ItemDao dao; @Test public void testAdd() { // issue -> testing ADD but using LIST int oldSize = dao.list().siz

如何在不使用“查找”的情况下测试DAO中的“添加”?

在下面的代码中,问题是,我不能使用dao.list()。size()来测试dao.add () ,反之亦然。 这种方法是正常还是不正确? 如果不正确,如何改进? public class ItemDaoTest { // dao to test @Autowired private ItemDao dao; @Test public void testAdd() { // issue -> testing ADD but using LIST int oldSize = dao.list().size(); dao.add(new Item("stuff"));

java.sql.SQLException: Io exception: Broken pipe how to recover without restart?

In my application I use connection to Oracle, when connection lost and I try to re-connect I receive exception: java.sql.SQLException: Io exception: Broken pipe at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.j

java.sql.SQLException:Io异常:断开的管道如何恢复而不重新启动?

在我的应用程序中,我使用连接到Oracle,当连接丢失,并尝试重新连接时,我收到异常: java.sql.SQLException: Io exception: Broken pipe at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:273) at oracle.jdbc.dri

MediaPlayer stops and restarts

I get a weird error. I play with a MediaPlayer a mediastream (like shoutcast or icecast). Sometimes suddenly on playing stream (total random) happens a error, the stream stops and restart. OnErrorListener don't get triggered! Logcat: 03-02 17:50:36.274: W/MediaPlayer(16799): info/warning (702, 0) 03-02 17:50:36.274: I/MediaPlayer(16799): Info (702,0) or like this: 03-02 17:50:14.250

MediaPlayer停止并重新启动

我有一个奇怪的错误。 我使用MediaPlayer播放媒体流(如shoutcast或icecast)。 有时突然在播放流(总随机)发生错误,流停止并重新启动。 OnErrorListener不会被触发! logcat的: 03-02 17:50:36.274: W/MediaPlayer(16799): info/warning (702, 0) 03-02 17:50:36.274: I/MediaPlayer(16799): Info (702,0) 或者像这样: 03-02 17:50:14.250: W/MediaPlayer(16799): info/warning (703, 0) 03-02 17:50:14.250: W/Me

Java to Excel 2010

I have a piece of code which is creating an Excel file by using an open source library named OpenXLS-6.0.6. My pc has Windows XP Professional and Office 2003. However I have notice that since I have migrated to Windows 7 and Office 2010, I am not able to open the generated Excel file anymore. I went to the OpenXLS website and indeed is specified that: "Compatible with Excel '97-2003 (.

Java到Excel 2010

我有一段代码,它使用名为OpenXLS-6.0.6的开源库创建Excel文件。 我的电脑有Windows XP Professional和Office 2003.但是我注意到,由于我已经迁移到Windows 7和Office 2010,我无法打开生成的Excel文件了。 我去了OpenXLS网站,确实指出:“与Excel '97-2003(.xls)文件格式兼容” 是否有人知道能够生成与Office 2010兼容的Excel文件的库? 我对ExcelAPI和POI进行了快速检查,但提到他们处理Excel到Office 2003版本(至

Where to find a framework similar to XNA on Java

I'm right now a C#/Java developer, and I've been having a great time on XNA with C#.NET. But I want to try developing 3d on Java, as it's portable and I haven't yet tried OpenGL out yet. I ran into a problem where there were many possibilities here: jMonkeyEngine Avatrix3D Ardor3D Java3D - I haven't actually looked into heavily, it seems interesting, but i would pr

在哪里可以找到类似于Java的XNA的框架

我现在是一名C#/ Java开发人员,并且我一直在XNA上玩C#.NET。 但我想尝试在Java上开发3D,因为它是可移植的,我还没有尝试过OpenGL。 我遇到了一个问题,这里有很多可能性: jMonkeyEngine Avatrix3D Ardor3D Java3D - 我并没有真正看重过,这似乎很有趣,但我更希望看到人们真正先说的是什么。 如果这实际上是我一直在寻找的东西,那就太棒了。 缺点是我相信支持水平非常低。 我主要研究了JME,后者实际上更

Browser Authentication via HttpURLConnection

Currently I am working on the implementation of TMDb API. There is a method called User Authentication. I have successfully implemented the Step 1 Step 1: Generate a Request Token Start by making an API call to the new token method. This will return a new request token that will be valid for 60 minutes. The request token is not authorized by the user at this stage. Request tokens are API

通过HttpURLConnection进行浏览器身份验证

目前我正在研究TMDb API的实现。 有一种称为用户认证的方法。 我已经成功实施了第一步 步骤1:生成请求标记 首先对新的令牌方法进行API调用。 这将返回一个新的请求标记,该标记将在60分钟内有效。 请求令牌在此阶段未被用户授权。 请求令牌是API帐户特定的,并且是第2步中您的应用程序和用户之间的联系。 对于第1步,我有以下代码: URL url = new URL("http://api.themoviedb.org/3/authentication/token/new?api_k

What Javascript framework integrates well with Grails?

Most of the applications that we produce for the front end uses Grails and we love it to death but we are exploring Javascript frameworks such as backbone.js, ember.js for templating, reusability. We are comfortable and familiar with json and would like to know what are some experiences and recommendations for a Javascript framework that plays nice with Grails. Would like to understand the eva

什么Javascript框架与Grails完美集成?

我们为前端生成的大多数应用程序都使用Grails,我们喜欢它,但我们正在探索Javascript框架,如backbone.js,ember.js用于模板化,可重用性。 我们对json很熟悉并且很熟悉,并且想知道对于和Grails很好的Javascript框架有什么经验和建议。 想了解评估标准,实施成本和涉及的学习曲线。 backbone是完全灵活的框架,并且可以和grails一起使用而不会有任何痛苦(我已经使用Grails)。 我与大多数js库(jquery,zepto等)兼容,

Eclipse debugger "jumps" skipping important code

I have a weird problem debugging an android application. To be accurate, I copy here the exact code I'm running on: // Get the puzzles from cache List<PuzzleDetails> newPuzzles = m_cachedPuzzles.getPuzzles(count); if(newPuzzles.size() > 0){ // Remove from cache m_cachedPuzzles.removePuzzles(newPuzzles); // LINE (A) // Add the new puzzles from cache immediate

Eclipse调试器“跳转”跳过重要的代码

调试Android应用程序时出现奇怪的问题。 为了准确,我在这里复制我正在运行的确切代码: // Get the puzzles from cache List<PuzzleDetails> newPuzzles = m_cachedPuzzles.getPuzzles(count); if(newPuzzles.size() > 0){ // Remove from cache m_cachedPuzzles.removePuzzles(newPuzzles); // LINE (A) // Add the new puzzles from cache immediately m_ownedPuzzles.addPuzzles(newP

Analog of ORACLE function MONTHS

Java是否具有Oracle的函数MONTHS_BETWEEN某些类比? You can do that with : public static int monthsBetween(Date minuend, Date subtrahend){ Calendar cal = Calendar.getInstance(); cal.setTime(minuend); int minuendMonth = cal.get(Calendar.MONTH); int minuendYear = cal.get(Calendar.YEAR); cal.setTime(subtrahend); int subtrahendMonth = cal.get(Calendar.MONTH);

ORACLE函数MONTHS的模拟

Java是否具有Oracle的函数MONTHS_BETWEEN某些类比? 你可以这样做: public static int monthsBetween(Date minuend, Date subtrahend){ Calendar cal = Calendar.getInstance(); cal.setTime(minuend); int minuendMonth = cal.get(Calendar.MONTH); int minuendYear = cal.get(Calendar.YEAR); cal.setTime(subtrahend); int subtrahendMonth = cal.get(Calendar.MONTH); int

Configuring JDO in Spring 3.1?

I used to have all my DAOs extend the JdoDaoSupport class which is now deprecated in Spring 3.1. I've made my own AbstractJdoDao class which wraps the PersistenceManagerFactory and all the DAOs extend from there. Is that the way I should be doing? Also in the documentation on JDO, it seems that the direct instantiation of PersistenceManagerFactory is not the default option, but to use Loc

在Spring 3.1中配置JDO?

我曾经让我所有的DAO扩展JdoDaoSupport类,现在在Spring 3.1中已经弃用了它。 我已经创建了自己的AbstractJdoDao类,它包装了PersistenceManagerFactory并且所有的DAO都从那里延伸出来。 这是我应该怎么做的方式? 同样在JDO的文档中,似乎PersistenceManagerFactory的直接实例化不是默认选项,而是使用包装在TransactionAwarePersistenceManagerFactoryProxy LocalPersistenceManagerFactoryBean 。 如何正确地实例化这些b