Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-8038 java.lang.ClassCastException with compatibility mode and te…
…xt content
- Loading branch information
Showing
9 changed files
with
92 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
commons/src/main/java/org/infinispan/commons/marshall/UTF8StringMarshaller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.infinispan.commons.marshall; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
||
public final class UTF8StringMarshaller extends StringMarshaller { | ||
|
||
public UTF8StringMarshaller() { | ||
super(UTF_8); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...de-it/src/test/java/org/infinispan/it/compatibility/EmbeddedRestHotRodWithStringTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.infinispan.it.compatibility; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
import org.apache.commons.httpclient.HttpClient; | ||
import org.apache.commons.httpclient.HttpMethod; | ||
import org.apache.commons.httpclient.HttpStatus; | ||
import org.apache.commons.httpclient.methods.EntityEnclosingMethod; | ||
import org.apache.commons.httpclient.methods.GetMethod; | ||
import org.apache.commons.httpclient.methods.PutMethod; | ||
import org.apache.commons.httpclient.methods.StringRequestEntity; | ||
import org.infinispan.client.hotrod.RemoteCache; | ||
import org.infinispan.commons.marshall.UTF8StringMarshaller; | ||
import org.infinispan.configuration.cache.CacheMode; | ||
import org.infinispan.test.AbstractInfinispanTest; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
@Test(groups = "functional", testName = "it.compatibility.EmbeddedRestHotRodWithStringTest") | ||
public class EmbeddedRestHotRodWithStringTest extends AbstractInfinispanTest { | ||
|
||
CompatibilityCacheFactory<String, Object> cacheFactory; | ||
|
||
@BeforeClass | ||
protected void setup() throws Exception { | ||
cacheFactory = new CompatibilityCacheFactory<String, Object>("testCache", new UTF8StringMarshaller(), CacheMode.LOCAL).setup(); | ||
} | ||
|
||
@AfterClass | ||
protected void teardown() { | ||
CompatibilityCacheFactory.killCacheFactories(cacheFactory); | ||
} | ||
|
||
public void testRestPutStringHotRodGet() throws Exception { | ||
final String key = "1"; | ||
|
||
// 1. Put text content with REST | ||
EntityEnclosingMethod put = new PutMethod(cacheFactory.getRestUrl() + "/" + key); | ||
put.setRequestEntity(new StringRequestEntity("<hey>ho</hey>", "application/xml", "UTF-8")); | ||
HttpClient restClient = cacheFactory.getRestClient(); | ||
restClient.executeMethod(put); | ||
assertEquals(HttpStatus.SC_OK, put.getStatusCode()); | ||
assertEquals("", put.getResponseBodyAsString().trim()); | ||
|
||
// 3. Get with Hot Rod | ||
assertEquals("<hey>ho</hey>", cacheFactory.getHotRodCache().get(key)); | ||
|
||
final String newKey = "2"; | ||
final String newValue = "<let's>go</let's>"; | ||
|
||
//4. Put text content with Hot Rod | ||
RemoteCache<String, Object> hotRodCache = cacheFactory.getHotRodCache(); | ||
hotRodCache.put(newKey, newValue); | ||
|
||
//5. Read with rest | ||
HttpMethod get = new GetMethod(cacheFactory.getRestUrl() + "/" + newKey); | ||
cacheFactory.getRestClient().executeMethod(get); | ||
assertEquals(HttpStatus.SC_OK, get.getStatusCode()); | ||
assertEquals(newValue, get.getResponseBodyAsString()); | ||
} | ||
|
||
} |