ssh関連テスト
テストはあまり重視していませんでしたが、問題が発生した時はサーバーを開いてどこでデバッグしていますか?問題があったらjunnitでユニットテストをしたいですが、忘れてしまいました.どうしたらいいですか?悲しいです.今まとめてみます.これからはこんなことが起こらないと思います.
1、Hibernateの語句テスト
configre()メソッドはデフォルトでは、classipathの下でhibernate.cfg.xmlまたはhibernation.propertiesファイルを探しています.名前が違ったらCofigration cfg=new Configration().configure("myxample.xml")を使います.
2、Springテスト
暇があったら更新してください.
1、Hibernateの語句テスト
SessionFactory sf=new Configuration().configure().buildSessionFactory();
Session session=sf.openSession();
Query q=session.createQuery("from Article a where a.banner.banner.id=1");
List l=q.list();
configre()メソッドはデフォルトでは、classipathの下でhibernate.cfg.xmlまたはhibernation.propertiesファイルを探しています.名前が違ったらCofigration cfg=new Configration().configure("myxample.xml")を使います.
2、Springテスト
public abstract class SpringTestCaseBase extends AbstractTransactionalDataSourceSpringContextTests {
protected SimpleDateFormat sdf;
public SpringTestCaseBase() {
// query the protected variables to implement denpendency injection automatically,
// so we don't need to write settor and gettor methods anymore.
this.setPopulateProtectedVariables(true);
sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setTimeZone(TimeZone.getDefault());
}
protected String[] getConfigLocations() {
return new String[] { "file:web/WEB-INF/applicationContext*.xml",
"file:web/WEB-INF/test-ApplicationContext*.xml"};
}
protected void flushSession(){
SessionFactory sessionFactory = (SessionFactory)applicationContext.getBean("sessionFactory");
sessionFactory.getCurrentSession().flush();
}
}
暇があったら更新してください.