Skip to content

Commit

Permalink
NCBC-253: Raise exception on FlushAll when called on CouchbaseNode
Browse files Browse the repository at this point in the history
Change-Id: I910a9f903af65ccbb0a3656873ca1d6f4bb4c12d
Reviewed-on: http://review.couchbase.org/26268
Reviewed-by: Saakshi Manocha <saakshi.manocha@globallogic.com>
Tested-by: Saakshi Manocha <saakshi.manocha@globallogic.com>
  • Loading branch information
jzablocki authored and saakshimanocha committed May 14, 2013
1 parent 6f1a2da commit a735ef6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Couchbase.Tests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<configSections>
<section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
<section name="min-config" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
<section name="memcached-config" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
<section name="pools-config" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
<section name="pools-default-config" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
<section name="heartbeat-config-on" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
Expand Down Expand Up @@ -58,6 +59,11 @@
<socketPool connectionTimeout="00:00:30" />
</couchbase>

<memcached-config>
<servers bucket="memached" bucketPassword="">
<add uri="http://localhost:8091/pools"/>
</servers>
</memcached-config>
<min-config>
<servers bucket="default" bucketPassword="" username="Administrator" password="password">
<add uri="http://localhost:8091/pools"/>
Expand Down
1 change: 1 addition & 0 deletions src/Couchbase.Tests/Couchbase.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Compile Include="ConfigHelperTests.cs" />
<Compile Include="CouchbaseClientExtensionsTests.cs" />
<Compile Include="CouchbaseClientGetWithLockTests.cs" />
<Compile Include="CouchbaseClientMemcachedTests.cs" />
<Compile Include="CouchbaseClientSpatialViewTests.cs" />
<Compile Include="CouchbaseClientViewTests.cs" />
<None Include="Data\ThingViews.json">
Expand Down
30 changes: 30 additions & 0 deletions src/Couchbase.Tests/CouchbaseClientMemcachedTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Couchbase.Configuration;
using System.Configuration;
using Enyim.Caching;

namespace Couchbase.Tests
{
[TestFixture]
public class CouchbaseClientMemcachedTests : CouchbaseClientTestsBase
{
[ExpectedException(typeof(NotImplementedException))]
[Test]
public void When_FlushAll_Is_Called_On_CouchbaseNode_Not_Implemented_Exception_Is_Raised()
{
_Client.FlushAll();
}

[Test]
public void When_FlushAll_Is_Called_On_BinaryNode_No_Exception_Is_Raised()
{
var config = ConfigurationManager.GetSection("memcached-config") as CouchbaseClientSection;
var client = new CouchbaseClient(config);
client.FlushAll();
}
}
}
10 changes: 10 additions & 0 deletions src/Couchbase/CouchbaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,16 @@ private static T If<T>(T input, Action<T> check)
}

#endregion

#region MemcachedClient overrides
public new void FlushAll()
{
var couchbaseNodes = poolInstance.GetWorkingNodes().Where(n => n is CouchbaseNode);
if (couchbaseNodes.Count() > 0)
throw new NotImplementedException("To flush a Couchbase bucket, use the Couchbase.Management API.");
base.FlushAll();
}
#endregion
}
}

Expand Down

0 comments on commit a735ef6

Please sign in to comment.