Hi Johan,
The issue is local to the account. I created a second account with an empty
calendar to test against, and the same issue does not appear.
Below is the MSTest class I used, with several test cases. You may note that
the test class subclasses another class, but only to gain easy access to the
testing config class used by all my test classes. Other users should be able
to revise this code easily to suit their own testing environment.
Interestingly, the errors aren't 100% consistent. Two hours ago when I ran
this against the problematic account, both Update and Delete generated the
500 error, but querying the event by its ID did not. 10 minutes ago when I
ran the tests multiple times, Updating and querying got an error, but
Deleting did not. Now all three test methods experience the error. I run
each of the test methods separately (i.e. not in the same test run), so
there should be absolutely no dependency between them to cause this change
in behaviour.
If at all possible, I would like to know if there is a solution to this
problem that does not require migrating all of the calendars' contents over
to an entirely new account!
Thanks,
S
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Google.GData.Calendar;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.AccessControl;
namespace TrainingTest.Handlers.Calendar
{
/// <summary>
/// GoogleCalendarAPIEventsTest exists exclusively to troubleshoot
Internal Server (500) Errors that
/// the google server is returning increasingly frequently when trying
to update events in calendars
/// belonging to the Training System.
/// </summary>
[TestClass]
public class GoogleCalendarAPIEventsTest : TestClass
{
private CalendarService CalService;
private string ServiceName = "test_TrainingSystem_CalendarEvents";
private string Username
{
get
{
return Config.CalendarUserName;
}
}
private string Password
{
get
{
return Config.CalendarPassword;
}
}
private string TestCalendarId
{
get
{
return Config.TestCalendarId;
}
}
/// <summary>
/// Gets the service that connects to google calendar
/// </summary>
private CalendarService Service
{
get
{
if (CalService == null)
{
CalService = new CalendarService(ServiceName);
CalService.setUserCredentials(Username, Password);
}
return CalService;
}
}
public GoogleCalendarAPIEventsTest()
{
}
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
[TestMethod]
public void TestUpdateCalendarEvent()
{
EventEntry newEntry = CreateTestEvent("EVENT TO UPDATE", "event
description", "event location");
// UPDATE THE EVENT
newEntry.Title = new
AtomTextConstruct(AtomTextConstructElementType.Title, "updated event
title");
newEntry.Update(); // Internal Server Error (500)
}
[TestMethod]
public void TestDeleteCalendarEvent()
{
EventEntry newEntry = CreateTestEvent("EVENT TO DELETE", "event
to be deleted", "event location");
// DELETE THE EVENT
newEntry.Delete(); // Internal Server Error (500)
}
[TestMethod]
public void TestQueryCalendarEventByID()
{
EventEntry newEntry = CreateTestEvent("EVENT TO QUERY", "event
to query by id", "location");
// QUERY FOR THE EVENT
string eventUri = string.Format("
http://www.google.com/calendar/feeds/{0}/private/full/{1}",
TestCalendarId, newEntry.EventId);
EventEntry queryEntry = (EventEntry)Service.Get(eventUri); //
Internal Server Error (500)
Assert.IsNotNull(queryEntry);
}
private EventEntry CreateTestEvent(string eventTitle, string
eventSummary, string eventLocation)
{
string calendarUri = string.Format("
http://www.google.com/calendar/feeds/{0}/private/full", TestCalendarId);
EventQuery query = new EventQuery(calendarUri);
EventFeed feed = Service.Query(query);
EventEntry entry = new EventEntry(eventTitle, eventSummary,
eventLocation);
entry.Times.Clear();
entry.Times.Add(new Google.GData.Extensions.When
{
StartTime = DateTime.Now.AddHours(1),
EndTime = DateTime.Now.AddHours(2)
});
return feed.Insert(entry);
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html