List of usage examples for org.apache.ibatis.session SqlSession rollback
void rollback();
From source file:com.bibisco.manager.TipManager.java
License:GNU General Public License
public static void disableTip(String pStrTipCode) { mLog.debug("Start disableTip(" + pStrTipCode + ")"); SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryBibisco(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {// ww w .j av a 2 s . c o m PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lProperties = new Properties(); lProperties.setProperty(pStrTipCode); lProperties.setValue("false"); lPropertiesMapper.updateByPrimaryKey(lProperties); lSqlSession.commit(); } catch (Throwable t) { mLog.error(t); lSqlSession.rollback(); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } mLog.debug("End disableTip(" + pStrTipCode + ")"); }
From source file:com.bibisco.test.ImageManagerTest.java
License:GNU General Public License
@Before @After/*w w w . ja v a2 s . c o m*/ public void init() throws ConfigurationException, IOException { SqlSessionFactory lSqlSessionFactory = AllTests.getBibiscoSqlSessionFactory(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try { PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lProperties = new Properties(); lProperties.setProperty("projectsDirectory"); lProperties.setValue("C:/temp/bibisco/projects"); lPropertiesMapper.updateByPrimaryKey(lProperties); lSqlSession.commit(); } catch (Throwable t) { lSqlSession.rollback(); } finally { lSqlSession.close(); } PropertiesManager.getInstance().reload(); }
From source file:com.bibisco.test.LocaleManagerTest.java
License:GNU General Public License
@Before @After// w w w . ja va 2 s . co m public void init() { SqlSessionFactory lSqlSessionFactory = AllTests.getBibiscoSqlSessionFactory(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try { PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lProperties = new Properties(); lProperties.setProperty("locale"); lProperties.setValue(""); lPropertiesMapper.updateByPrimaryKey(lProperties); lSqlSession.commit(); } catch (Throwable t) { lSqlSession.rollback(); } finally { lSqlSession.close(); } PropertiesManager.getInstance().reload(); }
From source file:com.bibisco.test.ProjectManagerTest.java
License:GNU General Public License
@Before public void init() throws ConfigurationException, IOException, InterruptedException { AllTests.cleanProjectsDirectory();/*from w w w . j a v a2s .c o m*/ SqlSessionFactory lSqlSessionFactory = AllTests.getBibiscoSqlSessionFactory(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try { PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lProperties = new Properties(); lProperties.setProperty("projectsDirectory"); lProperties.setValue(AllTests.BIBISCO_PROJECTS_DIR); lPropertiesMapper.updateByPrimaryKey(lProperties); lSqlSession.commit(); } catch (Throwable t) { lSqlSession.rollback(); } finally { lSqlSession.close(); } PropertiesManager.getInstance().reload(); }
From source file:com.bibisco.test.ProjectManagerTest.java
License:GNU General Public License
private void setNonExistentProjectDir() { SqlSessionFactory lSqlSessionFactory = AllTests.getBibiscoSqlSessionFactory(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {//from www . j av a2 s .co m PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lProperties = new Properties(); lProperties.setProperty("projectsDirectory"); lProperties.setValue("C:/temp/bibiscotto/projects"); lPropertiesMapper.updateByPrimaryKey(lProperties); lSqlSession.commit(); } catch (Throwable t) { lSqlSession.rollback(); } finally { lSqlSession.close(); } PropertiesManager.getInstance().reload(); }
From source file:com.bibisco.test.ProjectManagerTest.java
License:GNU General Public License
public void emptyProjectsDirectory() { SqlSessionFactory lSqlSessionFactory = AllTests.getBibiscoSqlSessionFactory(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {/*from www.jav a 2 s.co m*/ PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lProperties = new Properties(); lProperties.setProperty("projectsDirectory"); lProperties.setValue(""); lPropertiesMapper.updateByPrimaryKey(lProperties); lSqlSession.commit(); } catch (Throwable t) { lSqlSession.rollback(); } finally { lSqlSession.close(); } PropertiesManager.getInstance().reload(); }
From source file:com.bibisco.test.PropertiesManagerTest.java
License:GNU General Public License
@Before @After/*from w w w . j a v a 2 s . c o m*/ public void init() { SqlSessionFactory lSqlSessionFactory = AllTests.getBibiscoSqlSessionFactory(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try { PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lProperties = new Properties(); lProperties.setProperty("projectsDirectory"); lProperties.setValue(""); lPropertiesMapper.updateByPrimaryKey(lProperties); lProperties = new Properties(); lProperties.setProperty("socialMediaTip"); lProperties.setValue("true"); lPropertiesMapper.updateByPrimaryKey(lProperties); lProperties = new Properties(); lProperties.setProperty("locationsdndTip"); lProperties.setValue("true"); lPropertiesMapper.updateByPrimaryKey(lProperties); lSqlSession.commit(); } catch (Throwable t) { lSqlSession.rollback(); } finally { lSqlSession.close(); } PropertiesManager.getInstance().reload(); }
From source file:com.bibisco.test.RichTextEditorSettingsManagerTest.java
License:GNU General Public License
@Before @After/* w w w . jav a2 s . c o m*/ public void init() { SqlSessionFactory lSqlSessionFactory = AllTests.getBibiscoSqlSessionFactory(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try { PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lProperties = new Properties(); lProperties.setProperty("font"); lProperties.setValue("courier"); lPropertiesMapper.updateByPrimaryKey(lProperties); lProperties = new Properties(); lProperties.setProperty("font-size"); lProperties.setValue("medium"); lPropertiesMapper.updateByPrimaryKey(lProperties); lProperties = new Properties(); lProperties.setProperty("indentParagraphEnabled"); lProperties.setValue("true"); lPropertiesMapper.updateByPrimaryKey(lProperties); lProperties = new Properties(); lProperties.setProperty("spellCheckEnabled"); lProperties.setValue("true"); lPropertiesMapper.updateByPrimaryKey(lProperties); lProperties = new Properties(); lProperties.setProperty("autoSaveEnabled"); lProperties.setValue("true"); lPropertiesMapper.updateByPrimaryKey(lProperties); lSqlSession.commit(); } catch (Throwable t) { lSqlSession.rollback(); } finally { lSqlSession.close(); } PropertiesManager.getInstance().reload(); }
From source file:com.bibisco.test.TipManagerTest.java
License:GNU General Public License
@Test public void testDonationTip29DaysFromNow() { DateFormat lDateFormat = new SimpleDateFormat(DATE_FORMAT); Date lDate29DaysFromNow = DateUtils.addDays(new Date(), -29); SqlSessionFactory lSqlSessionFactory = AllTests.getBibiscoSqlSessionFactory(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {/*from w w w. j a va 2 s. c o m*/ PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lProperties = new Properties(); lProperties.setProperty("donationTip"); lProperties.setValue(lDateFormat.format(lDate29DaysFromNow)); lPropertiesMapper.updateByPrimaryKey(lProperties); lSqlSession.commit(); } catch (Throwable t) { lSqlSession.rollback(); } finally { lSqlSession.close(); } PropertiesManager.getInstance().reload(); TipSettings lTipSettings = TipManager.load(); Assert.assertEquals(lTipSettings.isDonationTip(), false); }
From source file:com.bibisco.test.TipManagerTest.java
License:GNU General Public License
@Test public void testDonationTip30DaysFromNow() { DateFormat lDateFormat = new SimpleDateFormat(DATE_FORMAT); Date lDate29DaysFromNow = DateUtils.addDays(new Date(), -30); SqlSessionFactory lSqlSessionFactory = AllTests.getBibiscoSqlSessionFactory(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try {/* w ww. j a v a 2 s . c om*/ PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lProperties = new Properties(); lProperties.setProperty("donationTip"); lProperties.setValue(lDateFormat.format(lDate29DaysFromNow)); lPropertiesMapper.updateByPrimaryKey(lProperties); lSqlSession.commit(); } catch (Throwable t) { lSqlSession.rollback(); } finally { lSqlSession.close(); } PropertiesManager.getInstance().reload(); TipSettings lTipSettings = TipManager.load(); Assert.assertEquals(lTipSettings.isDonationTip(), true); }