Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Spencer andrewspencer

View GitHub Profile
@andrewspencer
andrewspencer / StringUtil.java
Created May 2, 2011
Remove accents from a String
View StringUtil.java
package net.andrewspencer.util;
import sun.text.Normalizer; // java.text.Normalizer in 1.6
/**
* Here's how to remove accents in Java 1.5.
* NB Doesn't separate ligatures.
*/
// WARNING Uses unofficial Sun classes, so JVM-dependent.
// Normalizer became standard in Java 1.6, though.
@andrewspencer
andrewspencer / FbMultipleCheckableBeans.java
Created Mar 24, 2011
Multiple dynamic checkboxes in Struts 1.x using DisplayTag
View FbMultipleCheckableBeans.java
package net.andrewspencer.gist.multiple-checkboxes-struts;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
@andrewspencer
andrewspencer / EqualDataSetAssertBuilder.java
Created Dec 17, 2010
EqualDataSetAssertBuilder: a wrapper around DbUnitAssert.assertEqualsIgnoreCols(), DBUnit's post-test dataset equality assertion, to allow comparing multiple tables instead of just one table at a time.
View EqualDataSetAssertBuilder.java
import java.util.HashMap;
import java.util.Map;
import org.dbunit.DatabaseUnitException;
import org.dbunit.assertion.DbUnitAssert;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.ITable;
import org.dbunit.dataset.filter.DefaultColumnFilter;
/**
@andrewspencer
andrewspencer / AbstractSpringTestNGDBUnitTest.java
Created Dec 17, 2010
AbstractSpringTestNGDBUnitTest: adds DBUnit functionality to Spring's base class for Spring-context aware TestNG tests. To use, subclass and provide XML dataset and DTD files (at locations indicated in API comments).
View AbstractSpringTestNGDBUnitTest.java
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import javax.annotation.Resource;
import org.dbunit.DefaultDatabaseTester;
import org.dbunit.IDatabaseTester;
@andrewspencer
andrewspencer / UserTypeSupport.java
Created Dec 15, 2010
Base class for Hibernate UserTypes
View UserTypeSupport.java
package net.andrewspencer.util.hibernate;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.hibernate.HibernateException;