Donnerstag, 29. Januar 2015

Mocking singletons....


 public class LicenseDataLocator {
private static LicenseData licenseData;

    public static synchronized LicenseData getLicenseData() {
        if (licenseData == null) {
            licenseData = new LicenseDataLocator().readLicenseData();
        }
        return licenseData;
    }
   

// here you can insert your mock.
    public static void setLicenseData(LicenseData licenseData) {
        LicenseDataLocator.licenseData = licenseData;
    }

Keine Kommentare:

Kommentar veröffentlichen