Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 146472 Details for
Bug 288309
detect changes using date compare when time zone available on repository
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
updated patch with unit tests
clipboard.txt (text/plain), 12.44 KB, created by
Robert Elves
on 2009-09-04 01:45:05 EDT
(
hide
)
Description:
updated patch with unit tests
Filename:
MIME Type:
Creator:
Robert Elves
Created:
2009-09-04 01:45:05 EDT
Size:
12.44 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.bugzilla.core >Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaVersion.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaVersion.java,v >retrieving revision 1.7 >diff -u -r1.7 BugzillaVersion.java >--- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaVersion.java 24 Jul 2009 12:07:14 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaVersion.java 4 Sep 2009 05:46:19 -0000 >@@ -30,7 +30,9 @@ > > public final static BugzillaVersion BUGZILLA_3_2 = new BugzillaVersion("3.2"); //$NON-NLS-1$ > >- public final static BugzillaVersion MAX_VERSION = new BugzillaVersion("3.2"); //$NON-NLS-1$ >+ public final static BugzillaVersion BUGZILLA_3_4 = new BugzillaVersion("3.4"); //$NON-NLS-1$ >+ >+ public final static BugzillaVersion MAX_VERSION = new BugzillaVersion("3.4"); //$NON-NLS-1$ > > private final int major; > >Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java,v >retrieving revision 1.24 >diff -u -r1.24 BugzillaAttributeMapper.java >--- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java 24 Jul 2009 12:07:14 -0000 1.24 >+++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java 4 Sep 2009 05:46:19 -0000 >@@ -83,7 +83,7 @@ > /** > * Note: Date formatters constructed within method for thread safety > */ >- private Date getDate(String attributeId, String dateString) { >+ protected Date getDate(String attributeId, String dateString) { > Date parsedDate = null; > > /** >Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java,v >retrieving revision 1.167 >diff -u -r1.167 BugzillaRepositoryConnector.java >--- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java 1 Sep 2009 04:52:08 -0000 1.167 >+++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java 4 Sep 2009 05:46:19 -0000 >@@ -68,6 +68,8 @@ > > private static final String DEADLINE_FORMAT = "yyyy-MM-dd"; //$NON-NLS-1$ > >+ private static final long HOUR = 1000 * 60 * 60; >+ > private final BugzillaTaskAttachmentHandler attachmentHandler = new BugzillaTaskAttachmentHandler(this); > > private final BugzillaTaskDataHandler taskDataHandler = new BugzillaTaskDataHandler(this); >@@ -76,7 +78,7 @@ > > protected static BugzillaLanguageSettings enSetting; > >- protected final static Set<BugzillaLanguageSettings> languages = new LinkedHashSet<BugzillaLanguageSettings>(); >+ protected static final Set<BugzillaLanguageSettings> languages = new LinkedHashSet<BugzillaLanguageSettings>(); > > @Override > public String getLabel() { >@@ -312,7 +314,14 @@ > if (resultCollector instanceof BugzillaTaskDataCollector) { > BugzillaTaskDataCollector bCollector = (BugzillaTaskDataCollector) resultCollector; > if (bCollector.getQueryTimestamp() != null) { >- event.setData(bCollector.getQueryTimestamp()); >+ Date queryDate = ((BugzillaAttributeMapper) mapper).getDate(BugzillaAttribute.DELTA_TS.getKey(), >+ bCollector.getQueryTimestamp()); >+ if (queryDate == null) { >+ event.setData(bCollector.getQueryTimestamp()); >+ } else { >+ // Ensure time is in right format >+ event.setData(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(queryDate)); //$NON-NLS-1$ >+ } > } > } > >@@ -488,15 +497,59 @@ > > String lastKnownMod = task.getAttribute(BugzillaAttribute.DELTA_TS.getKey()); > if (lastKnownMod != null) { >+ > TaskAttribute attrModification = taskData.getRoot().getMappedAttribute(TaskAttribute.DATE_MODIFICATION); >- if (attrModification != null) { >- return !lastKnownMod.equals(attrModification.getValue()); >- } >+ if (attrModification != null && attrModification.getValue() != null >+ && attrModification.getValue().length() > 0) { > >+ boolean cachedHasTZ = hasTimzone(lastKnownMod); >+ boolean repoHasTZ = hasTimzone(attrModification.getValue()); >+ if (!cachedHasTZ && !repoHasTZ) { // State 1 >+ return !lastKnownMod.equals(attrModification.getValue()); >+ } >+ >+ BugzillaAttributeMapper mapper = (BugzillaAttributeMapper) taskData.getAttributeMapper(); >+ Date oldModDate = mapper.getDate(BugzillaAttribute.DELTA_TS.getKey(), lastKnownMod); >+ Date newModDate = mapper.getDateValue(attrModification); >+ >+ // If either of the dates can't be parsed, fall back to string comparison >+ if (oldModDate == null) { >+ ((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, >+ "Unable to parse cached task modification timestamp " + lastKnownMod)); //$NON-NLS-1$ >+ return !lastKnownMod.equals(attrModification.getValue()); >+ } else if (newModDate == null) { >+ ((AbstractTask) task).setStatus(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN, >+ "Unable to parse incoming task modification timestamp " + attrModification.getValue())); //$NON-NLS-1$ >+ return !lastKnownMod.equals(attrModification.getValue()); >+ } >+ >+ if ((cachedHasTZ && !repoHasTZ) || (!cachedHasTZ && repoHasTZ)) { // State 2 (unlikely) || Sate 3 >+ long delta = Math.abs(newModDate.getTime() - oldModDate.getTime()); >+ if (delta == 0) { >+ return false; >+ } else if (delta > 0 && delta % HOUR == 0 && delta < 24 * HOUR) { >+ // If same time but in different time zones, ignore/migrate >+ return false; >+ } >+ return true; >+ } else if (cachedHasTZ && repoHasTZ) { //State 4 (of 4) >+ // Date Compare >+ return oldModDate.compareTo(newModDate) != 0; >+ } >+ } > } > return true; > } > >+ private boolean hasTimzone(String dateString) { >+ if (dateString == null || dateString.length() == 0) { >+ return false; >+ } >+ String[] parts = dateString.split(" "); //$NON-NLS-1$ >+ boolean hasTimeZone = (parts != null && parts.length == 3); >+ return hasTimeZone; >+ } >+ > @Override > public Collection<TaskRelation> getTaskRelations(TaskData taskData) { > List<TaskRelation> relations = new ArrayList<TaskRelation>(); >#P org.eclipse.mylyn.bugzilla.ui >Index: src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java,v >retrieving revision 1.94 >diff -u -r1.94 BugzillaRepositorySettingsPage.java >--- src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java 24 Jul 2009 12:08:07 -0000 1.94 >+++ src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java 4 Sep 2009 05:46:20 -0000 >@@ -55,7 +55,7 @@ > > private static final String LABEL_SHORT_LOGINS = Messages.BugzillaRepositorySettingsPage_local_users_enabled; > >- private static final String LABEL_VERSION_NUMBER = "2.18 - 3.2"; //$NON-NLS-1$ >+ private static final String LABEL_VERSION_NUMBER = "3.0 - 3.4"; //$NON-NLS-1$ > > private static final String TITLE = Messages.BugzillaRepositorySettingsPage_bugzilla_repository_settings; > >#P org.eclipse.mylyn.bugzilla.tests >Index: src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java,v >retrieving revision 1.1 >diff -u -r1.1 BugzillaRepositoryConnectorStandaloneTest.java >--- src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java 1 Sep 2009 04:13:56 -0000 1.1 >+++ src/org/eclipse/mylyn/bugzilla/tests/core/BugzillaRepositoryConnectorStandaloneTest.java 4 Sep 2009 05:46:20 -0000 >@@ -23,9 +23,12 @@ > import org.eclipse.mylyn.commons.net.AuthenticationType; > import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; > import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector; >+import org.eclipse.mylyn.internal.tasks.core.AbstractTask; > import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery; >+import org.eclipse.mylyn.internal.tasks.core.TaskTask; > import org.eclipse.mylyn.tasks.core.TaskRepository; > import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler; >+import org.eclipse.mylyn.tasks.core.data.TaskAttribute; > import org.eclipse.mylyn.tasks.core.data.TaskData; > import org.eclipse.mylyn.tasks.core.data.TaskDataCollector; > >@@ -52,6 +55,81 @@ > handler = connector.getTaskDataHandler(); > } > >+ public void testHasChanged() { >+ AbstractTask task = new TaskTask(repository.getConnectorKind(), repository.getRepositoryUrl(), "1"); >+ task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12"); >+ TaskData data = new TaskData(connector.getTaskDataHandler().getAttributeMapper(repository), >+ repository.getConnectorKind(), repository.getRepositoryUrl(), "1"); >+ TaskAttribute attribute = data.getRoot().createAttribute(BugzillaAttribute.DELTA_TS.getKey()); >+ >+ // Testing State 1 >+ >+ // Offline no timezone, repository no timezone, same time >+ attribute.setValue("2008-02-02 12:01:12"); >+ assertFalse(connector.hasTaskChanged(repository, task, data)); >+ >+ // Offline no timezone, repository no timezone, different date >+ attribute.setValue("2008-02-03 12:01:12"); >+ assertTrue(connector.hasTaskChanged(repository, task, data)); >+ >+ // Offline no timezone, repository no timezone, different time >+ attribute.setValue("2008-02-02 12:03:12"); >+ assertTrue(connector.hasTaskChanged(repository, task, data)); >+ >+ // Offline no timezone, repository no timezone, different (older) time >+ attribute.setValue("2008-02-02 12:03:00"); >+ assertTrue(connector.hasTaskChanged(repository, task, data)); >+ >+ // Testing Fuzzy States 2 & 3 >+ >+ // Offline have timezone, repository no timezone, same time >+ task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12 -0700"); >+ attribute.setValue("2008-02-02 12:01:12"); >+ assertFalse(connector.hasTaskChanged(repository, task, data)); >+ >+ // Offline have timezone, repository no timezone, different time >+ task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12 -0700"); >+ attribute.setValue("2008-02-02 12:01:13"); >+ assertTrue(connector.hasTaskChanged(repository, task, data)); >+ >+ // Offline no timezone, repository has timezone >+ task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12"); >+ attribute.setValue("2008-02-02 12:01:12 -0700"); >+ assertFalse(connector.hasTaskChanged(repository, task, data)); >+ >+ // Offline no timezone, repository has timezone and different time (fuzzy check doesn't pass) >+ attribute.setValue("2008-02-02 12:01:13 -0700"); >+ assertTrue(connector.hasTaskChanged(repository, task, data)); >+ >+ // Test backwards in time >+ task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2008-02-02 12:01:12"); >+ attribute.setValue("2008-02-02 12:01:03 -0700"); >+ assertTrue(connector.hasTaskChanged(repository, task, data)); >+ >+ // Testing State 4 >+ >+ // Same world time, reported wrt different time zones >+ task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04 00:00:00 PDT"); >+ attribute.setValue("2009-09-04 03:00:00 EDT"); >+ assertFalse(connector.hasTaskChanged(repository, task, data)); >+ >+ // Different times, same time zone >+ task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04 12:00:00 PDT"); >+ attribute.setValue("2009-09-04 12:00:01 PDT"); >+ assertTrue(connector.hasTaskChanged(repository, task, data)); >+ >+ // Same times, bogus format (string compare) >+ task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04 12:00:::01 PDT"); >+ attribute.setValue("2009-09-04 12:00:::01 PDT"); >+ assertFalse(connector.hasTaskChanged(repository, task, data)); >+ >+ // Same times, bogus format (string compare) >+ task.setAttribute(BugzillaAttribute.DELTA_TS.getKey(), "2009-09-04X12:00:::01 PDT"); >+ attribute.setValue("2009-09-04 12:00:::01 PDT"); >+ assertTrue(connector.hasTaskChanged(repository, task, data)); >+ >+ } >+ > /** > * This is the first test so that the repository credentials are correctly set for the other tests > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 288309
:
146301
|
146302
|
146472
|
146516
|
146776