Author: fmantek
Date: Fri Mar 16 09:41:15 2007
New Revision: 116
Modified:
trunk/clients/cs/src/core/collections.cs
trunk/clients/cs/src/core/request.cs
trunk/clients/cs/src/core/service.cs
trunk/clients/cs/src/unittests/blogger.cs
trunk/clients/cs/src/unittests/caltest.cs
trunk/clients/cs/src/unittests/objectmodelhelper.cs
trunk/clients/cs/src/unittests/unittests.cs
trunk/clients/cs/src/unittests/unittests.dll.config
Log:
Added another Blogger unittest (read-only access). removed some incorrect
tracemessage. Improved
inline documentation for the Service class. Also fixed calendar tests to
account for a change in the calendar service
Modified: trunk/clients/cs/src/core/collections.cs
==============================================================================
--- trunk/clients/cs/src/core/collections.cs (original)
+++ trunk/clients/cs/src/core/collections.cs Fri Mar 16 09:41:15 2007
@@ -268,7 +268,6 @@
return link;
}
}
- Tracing.TraceMsg("Found NULL service, probably mistake");
return null;
}
/////////////////////////////////////////////////////////////////////////////
Modified: trunk/clients/cs/src/core/request.cs
==============================================================================
--- trunk/clients/cs/src/core/request.cs (original)
+++ trunk/clients/cs/src/core/request.cs Fri Mar 16 09:41:15 2007
@@ -44,7 +44,7 @@
private StringCollection customHeaders; // holds any custom
headers to set
private String shardingCookie; // holds the sharding
cookie if returned
private WebProxy webProxy; // holds a webproxy to use
- private bool keepAlive;
// indicates wether or not to keep the connection alive
+ private bool keepAlive; // indicates wether or not
to keep the connection alive
/// <summary>Cookie setting header, returned from server</summary>
public const string SetCookieHeader = "Set-Cookie";
@@ -59,12 +59,15 @@
//////////////////////////////////////////////////////////////////////
public GDataRequestFactory(string userAgent)
{
- if (userAgent != null) {
- this.userAgent = userAgent + " " + GDataAgent;
- } else {
- this.userAgent = GDataAgent;
- }
- this.keepAlive = true;
+ if (userAgent != null)
+ {
+ this.userAgent = userAgent + " " + GDataAgent;
+ }
+ else
+ {
+ this.userAgent = GDataAgent;
+ }
+ this.keepAlive = true;
}
/////////////////////////////////////////////////////////////////////////////
@@ -110,18 +113,18 @@
set {this.webProxy = value;}
}
/////////////////////////////////////////////////////////////////////////////
-
-
//////////////////////////////////////////////////////////////////////
- /// <summary>indicates if the connection should be kept alive,
default
- /// is true</summary>
- /// <returns> </returns>
-
//////////////////////////////////////////////////////////////////////
- public bool KeepAlive
- {
- get {return this.keepAlive;}
- set {this.keepAlive = value;}
- }
-
/////////////////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////////
+ /// <summary>indicates if the connection should be kept alive, default
+ /// is true</summary>
+ /// <returns> </returns>
+ //////////////////////////////////////////////////////////////////////
+ public bool KeepAlive
+ {
+ get {return this.keepAlive;}
+ set {this.keepAlive = value;}
+ }
+
/////////////////////////////////////////////////////////////////////////////
internal bool hasCustomHeaders
{
@@ -336,7 +339,7 @@
}
web.ContentType = "application/atom+xml; charset=UTF-8";
web.UserAgent = this.factory.UserAgent;
- web.KeepAlive = this.factory.KeepAlive;
+ web.KeepAlive = this.factory.KeepAlive;
// add all custom headers
if (this.factory.hasCustomHeaders == true)
@@ -399,7 +402,9 @@
catch (WebException e)
{
Tracing.TraceCall("GDataRequest::Execute failed: " +
this.targetUri.ToString());
- throw new GDataRequestException("Execution of request failed:
" + this.targetUri.ToString(), e);
+ GDataRequestException gde = new
GDataRequestException("Execution of request failed: " +
this.targetUri.ToString(), e);
+ Tracing.TraceMsg("Exception text: " + gde.ResponseString);
+ throw gde;
}
if (this.webResponse is HttpWebResponse)
{
Modified: trunk/clients/cs/src/core/service.cs
==============================================================================
--- trunk/clients/cs/src/core/service.cs (original)
+++ trunk/clients/cs/src/core/service.cs Fri Mar 16 09:41:15 2007
@@ -70,7 +70,7 @@
//////////////////////////////////////////////////////////////////////
- /// <summary>default constructor, sets the default
GDataRequest</summary>
+ /// <summary>this will trigger the creation of an authenticating
service</summary>
//////////////////////////////////////////////////////////////////////
public Service(string service, string applicationName)
{
@@ -80,7 +80,7 @@
//////////////////////////////////////////////////////////////////////
- /// <summary>default constructor, sets the default
GDataRequest</summary>
+ /// <summary>this will trigger the creation of an authenticating
servicea</summary>
//////////////////////////////////////////////////////////////////////
public Service(string service, string applicationName, string library)
{
Modified: trunk/clients/cs/src/unittests/blogger.cs
==============================================================================
--- trunk/clients/cs/src/unittests/blogger.cs (original)
+++ trunk/clients/cs/src/unittests/blogger.cs Fri Mar 16 09:41:15 2007
@@ -68,6 +68,7 @@
{
authFactory.Handler = this.strAuthHandler;
}
+ FeedCleanup(this.bloggerURI, this.userName, this.passWord);
}
/////////////////////////////////////////////////////////////////////////////
@@ -77,10 +78,11 @@
[TearDown] public override void EndTest()
{
Tracing.ExitTracing();
- }
+ FeedCleanup(this.bloggerURI, this.userName, this.passWord);
+ }
/////////////////////////////////////////////////////////////////////////////
-
+
//////////////////////////////////////////////////////////////////////
/// <summary>private void ReadConfigFile()</summary>
@@ -365,12 +367,42 @@
}
/////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////
+ /// <summary>tests if we can access a public feed</summary>
+ //////////////////////////////////////////////////////////////////////
+ [Test] public void BloggerPublicFeedTest()
+ {
+ Tracing.TraceMsg("Entering BloggerPublicFeedTest");
+
+ FeedQuery query = new FeedQuery();
+ Service service = new Service(this.ServiceName,
this.ApplicationName);
+
+ String publicURI = (String) this.externalHosts[0];
+
+ if (publicURI != null)
+ {
+ service.RequestFactory = this.factory;
+
+ query.Uri = new Uri(publicURI);
+ AtomFeed feed = service.Query(query);
+
+ if (feed != null)
+ {
+ // look for the one with dinner time...
+ foreach (AtomEntry entry in feed.Entries)
+ {
+ Assert.IsTrue(entry.ReadOnly, "The entry should be
readonly");
+ }
+ }
+ }
+
+ }
+
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// <summary>runs an authentication test</summary>
//////////////////////////////////////////////////////////////////////
- [Ignore ("Currently used only for fill up")]
- [Test] public void GoogleStressTest()
+ [Test] public void BloggerStressTest()
{
Tracing.TraceMsg("Entering Blogger GoogleStressTest");
Modified: trunk/clients/cs/src/unittests/caltest.cs
==============================================================================
--- trunk/clients/cs/src/unittests/caltest.cs (original)
+++ trunk/clients/cs/src/unittests/caltest.cs Fri Mar 16 09:41:15 2007
@@ -72,7 +72,8 @@
authFactory.Handler = this.strAuthHandler;
}
- CalendarCleanup();
+ FeedCleanup(this.defaultCalendarUri, this.userName, this.passWord);
+
}
/////////////////////////////////////////////////////////////////////////////
@@ -81,7 +82,7 @@
//////////////////////////////////////////////////////////////////////
[TearDown] public override void EndTest()
{
- CalendarCleanup();
+ FeedCleanup(this.defaultCalendarUri, this.userName, this.passWord);
Tracing.ExitTracing();
}
/////////////////////////////////////////////////////////////////////////////
@@ -244,7 +245,7 @@
//////////////////////////////////////////////////////////////////////
/// <summary>runs an authentication test</summary>
//////////////////////////////////////////////////////////////////////
- [Ignore ("Currently broken on the server")]
+ [Ignore ("Currently broken on the server")]
[Test] public void CalendarXHTMLTest()
{
Tracing.TraceMsg("Entering CalendarXHTMLTest");
@@ -1101,60 +1102,7 @@
}
}
/////////////////////////////////////////////////////////////////////////////
-
-
- //////////////////////////////////////////////////////////////////////
- /// <summary>empty the calendar</summary>
- //////////////////////////////////////////////////////////////////////
- public void CalendarCleanup()
- {
- Tracing.TraceMsg("Entering CalendarCleanup");
-
- FeedQuery query = new FeedQuery();
- Service service = new Service();
-
-
- if (this.defaultCalendarUri != null)
- {
- if (this.userName != null)
- {
- NetworkCredential nc = new
NetworkCredential(this.userName, this.passWord);
- service.Credentials = nc;
- }
-
- GDataLoggingRequestFactory factory =
(GDataLoggingRequestFactory) this.factory;
- factory.MethodOverride = true;
- service.RequestFactory = this.factory;
-
- query.Uri = new Uri(this.defaultCalendarUri);
- AtomFeed calFeed = service.Query(query);
-
- int iCount=0;
-
- while (calFeed != null && calFeed.Entries.Count > 0)
- {
- // look for the one with dinner time...
- foreach (AtomEntry entry in
calFeed.Entries)
- {
- entry.Delete();
- iCount++;
- Tracing.TraceMsg("CalendarCleanup = deleting entry" +
iCount);
- }
- // just query the same query again.
- calFeed = service.Query(query);
- }
-
- Tracing.Assert(calFeed.Entries.Count ==0, "Feed should be
empty" );
-
- query.Uri = new Uri(this.defaultCalendarUri);
- calFeed = service.Query(query);
-
- Assert.AreEqual(0, calFeed.Entries.Count, "Feed should have no
more entries, it has: " + calFeed.Entries.Count);
- service.Credentials = null;
- factory.MethodOverride = false;
- }
- }
-
/////////////////////////////////////////////////////////////////////////////
+
}
/////////////////////////////////////////////////////////////////////////////
}
Modified: trunk/clients/cs/src/unittests/objectmodelhelper.cs
==============================================================================
--- trunk/clients/cs/src/unittests/objectmodelhelper.cs (original)
+++ trunk/clients/cs/src/unittests/objectmodelhelper.cs Fri Mar 16 09:41:15 2007
@@ -30,7 +30,7 @@
/// </summary>
public class ObjectModelHelper
{
- public static int DEFAULT_REMINDER_TIME = 27;
+ public static int DEFAULT_REMINDER_TIME = 30;
//////////////////////////////////////////////////////////////////////
/// <summary>creates a new, in memory atom entry</summary>
Modified: trunk/clients/cs/src/unittests/unittests.cs
==============================================================================
--- trunk/clients/cs/src/unittests/unittests.cs (original)
+++ trunk/clients/cs/src/unittests/unittests.cs Fri Mar 16 09:41:15 2007
@@ -96,6 +96,59 @@
//////////////////////////////////////////////////////////////////////
+ /// <summary>empty a feed</summary>
+ //////////////////////////////////////////////////////////////////////
+ protected void FeedCleanup(String uriToClean, String userName, String
pwd)
+ {
+ Tracing.TraceMsg("Entering BloggerCleanup");
+
+ FeedQuery query = new FeedQuery();
+ Service service = new Service();
+
+
+ if (uriToClean != null)
+ {
+ if (userName != null)
+ {
+ NetworkCredential nc = new NetworkCredential(userName,
pwd);
+ service.Credentials = nc;
+ }
+
+ GDataLoggingRequestFactory factory =
(GDataLoggingRequestFactory) this.factory;
+ factory.MethodOverride = true;
+ service.RequestFactory = this.factory;
+
+ query.Uri = new Uri(uriToClean);
+ AtomFeed feed = service.Query(query);
+
+ int iCount=0;
+
+ while (feed != null && feed.Entries.Count > 0)
+ {
+ // look for the one with dinner time...
+ foreach (AtomEntry entry in
feed.Entries)
+ {
+ entry.Delete();
+ iCount++;
+ Tracing.TraceMsg("Blogger Cleanup = deleting entry" +
iCount);
+ }
+ // just query the same query again.
+ feed = service.Query(query);
+ }
+
+ Tracing.Assert(feed.Entries.Count ==0, "Feed should be empty"
);
+
+ query.Uri = new Uri(uriToClean);
+ feed = service.Query(query);
+
+ Assert.AreEqual(0, feed.Entries.Count, "Feed should have no
more entries, it has: " + feed.Entries.Count);
+ service.Credentials = null;
+ factory.MethodOverride = false;
+ }
+ }
+
/////////////////////////////////////////////////////////////////////////////
+
+ //////////////////////////////////////////////////////////////////////
/// <summary>private void ReadConfigFile()</summary>
/// <returns> </returns>
//////////////////////////////////////////////////////////////////////
Modified: trunk/clients/cs/src/unittests/unittests.dll.config
==============================================================================
--- trunk/clients/cs/src/unittests/unittests.dll.config (original)
+++ trunk/clients/cs/src/unittests/unittests.dll.config Fri Mar 16 09:41:15 2007
@@ -24,6 +24,7 @@
iteration="3" requestlogging="true"/>
<unitTestExternalHosts>
+ <add key="HostGData"
value="http://googledataapis.blogspot.com/feeds/posts/default" />
<add key="Host1"
value="http://www.franklinmint.fm/2005/09/26/test_entry2.xml" />
<add key="Host2" value="http://www.atomenabled.org/atom.xml" />
<add key="Host4" value="http://www.oreillynet.com/pub/feed/25" />
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google 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://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---