/** * Test method for {@link ManagedResourceStore#checkForUpdate()} and {@link * ManagedResourceStore#getUpdateStatus()}. */ public void testCheckForUpdate() { final LocalServer ls = Factory.getInstance().createLocalServer(); ls.removeManagedStore(MANAGED_RESOURCE_STORE_NAME); final ManagedResourceStore mrs = ls.createManagedStore(MANAGED_RESOURCE_STORE_NAME); mrs.setManifestUrl(getTestManifestURL()); mrs.checkForUpdate(); delayTestFinish(5000); new Timer() { @Override public void run() { switch (mrs.getUpdateStatus()) { case ManagedResourceStore.UPDATE_CHECKING: case ManagedResourceStore.UPDATE_DOWNLOADING: schedule(500); break; case ManagedResourceStore.UPDATE_FAILED: fail("Failed to update the resource"); break; case ManagedResourceStore.UPDATE_OK: assertEquals("gwt-google-apis 0.1", mrs.getCurrentVersion()); // For some reason on FF getLastUpdateCheckTime() returns negative // values. // assertTrue(mrs.getLastUpdateCheckTime() > 0); finishTest(); break; } } }.schedule(500); }
/** * Test method for {@link ManagedResourceStore#setManifestUrl(String)} and {@link * ManagedResourceStore#getManifestUrl()}. */ public void testGetSetManifestUrl() { LocalServer ls = Factory.getInstance().createLocalServer(); ls.removeManagedStore(MANAGED_RESOURCE_STORE_NAME); ManagedResourceStore mrs = ls.createManagedStore(MANAGED_RESOURCE_STORE_NAME); mrs.setManifestUrl(getTestManifestURL()); assertEquals(getTestManifestURL(), mrs.getManifestUrl()); }
/** * Test method for {@link ManagedResourceStore#isEnabled()} and {@link * ManagedResourceStore#setEnabled(boolean)}. */ public void testIsEnabled() { LocalServer ls = Factory.getInstance().createLocalServer(); ls.removeManagedStore(MANAGED_RESOURCE_STORE_NAME); ManagedResourceStore mrs = ls.createManagedStore(MANAGED_RESOURCE_STORE_NAME); mrs.setEnabled(false); assertFalse(mrs.isEnabled()); mrs.setEnabled(true); assertTrue(mrs.isEnabled()); }
/** Test method for {@link ManagedResourceStore#setManifestUrl(String)}. */ public void disabledTestSetManifestURLNull() { LocalServer ls = Factory.getInstance().createLocalServer(); ls.removeManagedStore(MANAGED_RESOURCE_STORE_NAME); ManagedResourceStore mrs = ls.createManagedStore(MANAGED_RESOURCE_STORE_NAME); try { mrs.setManifestUrl(null); fail("Expected a NullPointerException"); } catch (NullPointerException e) { // Expected to get here } }
public void uploadFiles() { Desktop desktop = Factory.getInstance().createDesktop(); desktop.openFiles( new OpenFilesHandler() { public void onOpenFiles(OpenFilesEvent event) { uploadFiles(event.getFiles()); } }, false); }
@Override public void updateDistantDatabase() { fireOnStart(); fireOnTaskChange(I18N.CONSTANTS.synchronizerOrganizationUpload_0()); final Factory factory = Factory.getInstance(); if (factory != null) { final Database database = factory.createDatabase(); database.open(OnlineMode.LOCAL_DATABASE_NAME); try { OrganizationDAO.truncateTables(database); fireOnComplete(); } catch (DatabaseException ex) { Log.debug("Error while removing the organization dto from the local database.", ex); fireOnFailure( false, I18N.CONSTANTS.synchronizerOrganizationUpload_0_failed() + ex.getMessage()); } finally { try { database.close(); } catch (DatabaseException ex) { Log.debug("Database closing error.", ex); fireOnFailure( false, I18N.CONSTANTS.synchronizerOrganizationUpload_0_failed() + ex.getMessage()); } } } else fireOnFailure( false, I18N.CONSTANTS.synchronizerOrganizationUpload_0_failed() + "Google Gears isn't available."); }
/** Test method for {@link ManagedResourceStore#getName()}. */ public void testGetName() { LocalServer ls = Factory.getInstance().createLocalServer(); ls.removeManagedStore(MANAGED_RESOURCE_STORE_NAME); ManagedResourceStore mrs = ls.createManagedStore(MANAGED_RESOURCE_STORE_NAME); assertEquals(MANAGED_RESOURCE_STORE_NAME, mrs.getName()); }
/** Test method for {@link ManagedResourceStore#getCurrentVersion()}. */ public void testGetCurrentVersion() { final LocalServer ls = Factory.getInstance().createLocalServer(); ls.removeManagedStore(MANAGED_RESOURCE_STORE_NAME); final ManagedResourceStore mrs = ls.createManagedStore(MANAGED_RESOURCE_STORE_NAME); assertEquals("", mrs.getCurrentVersion()); }
/** Test method for {@link ManagedResourceStore#setManifestUrl(String)}. */ public void testSetManifestURLEmpty() { LocalServer ls = Factory.getInstance().createLocalServer(); ls.removeManagedStore(MANAGED_RESOURCE_STORE_NAME); ManagedResourceStore mrs = ls.createManagedStore(MANAGED_RESOURCE_STORE_NAME); mrs.setManifestUrl(""); }
@Override public void synchronizeLocalDatabase() { fireOnStart(); fireOnTaskChange(I18N.CONSTANTS.synchronizerOrganizationDownload_0()); final Factory factory = Factory.getInstance(); if (factory != null) { dispatcher.execute( new GetOrganization(authentication.getOrganizationId()), null, new AsyncCallback<OrganizationDTO>() { @Override public void onFailure(Throwable caught) { fireOnFailure( false, I18N.CONSTANTS.synchronizerOrganizationDownload_0_failed() + caught.getMessage()); } @Override public void onSuccess(OrganizationDTO result) { final Database database = factory.createDatabase(); database.open(OnlineMode.LOCAL_DATABASE_NAME); try { fireOnUpdate(0.1); fireOnTaskChange(I18N.CONSTANTS.synchronizerOrganizationDownload_1()); OrganizationDAO.createTablesIfNotExists(database); fireOnUpdate(0.2); fireOnTaskChange(I18N.CONSTANTS.synchronizerOrganizationDownload_2()); OrganizationDAO.insertOrReplaceOrganization(result, database); final LocalServer localServer = factory.createLocalServer(); final ResourceStore store = localServer.createStore(OnlineMode.LOCAL_DATABASE_NAME); fireOnUpdate(0.8); fireOnTaskChange(I18N.CONSTANTS.synchronizerOrganizationDownload_3()); store.capture( new ResourceStoreUrlCaptureHandler() { @Override public void onCapture(ResourceStoreUrlCaptureEvent event) { fireOnComplete(); } }, GWT.getModuleBaseURL() + "image-provider?" + FileUploadUtils.IMAGE_URL + "=" + result.getLogo()); } catch (DatabaseException ex) { Log.debug("Error while writing the organization dto to the local database.", ex); fireOnFailure( false, I18N.CONSTANTS.synchronizerOrganizationDownload_0_failed() + ex.getMessage()); } finally { try { database.close(); } catch (DatabaseException ex) { Log.debug("Database closing error.", ex); fireOnFailure( false, I18N.CONSTANTS.synchronizerOrganizationDownload_0_failed() + ex.getMessage()); } } } }); } else fireOnFailure( false, I18N.CONSTANTS.synchronizerOrganizationDownload_0_failed() + "Google Gears isn't available."); }