Header key pattern now support dot symbol (#24)

This commit is contained in:
Pavel Popov 2017-07-14 16:41:51 +03:00 committed by GitHub
parent cf4712086a
commit f4c5ed0125
5 changed files with 29 additions and 10 deletions

View File

@ -12,7 +12,7 @@
<packaging>pom</packaging>
<groupId>com.rbkmoney.woody</groupId>
<artifactId>woody</artifactId>
<version>1.1.4</version>
<version>1.1.5</version>
<description>Java implementation for Woody spec</description>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>woody</artifactId>
<groupId>com.rbkmoney.woody</groupId>
<version>1.1.4</version>
<version>1.1.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>woody</artifactId>
<groupId>com.rbkmoney.woody</groupId>
<version>1.1.4</version>
<version>1.1.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -22,7 +22,7 @@ import static com.rbkmoney.woody.api.interceptor.ext.ExtensionBundle.ContextBund
* Created by vpankrashkin on 23.01.17.
*/
public class MetadataExtensionBundle extends ExtensionBundle {
private static final Pattern KEY_PATTERN = Pattern.compile("[\\w-]{1,53}");
private static final Pattern KEY_PATTERN = Pattern.compile("[\\w-.]{1,53}");
public MetadataExtensionBundle(List<MetadataExtensionKit> extensionList) {
super(createClientBundle(extensionList), createServiceBundle(extensionList));

View File

@ -58,6 +58,9 @@ public class TestCustomMetadataExtension extends AbstractTest {
case 10:
assertEquals((Object) 1, ContextUtils.getCustomMetadataValue(IntExtension.instance.getExtension()));
break;
case 11:
assertEquals("test", ContextUtils.getCustomMetadataValue(String.class, "test.test.test"));
break;
default:
super.getOwner(id);
}
@ -65,12 +68,13 @@ public class TestCustomMetadataExtension extends AbstractTest {
}
};
OwnerServiceSrv.Iface rpcMetaClientToMetaSrv = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), Arrays.asList(IntExtension.instance), getUrlString("/rpc_cmeta"));
OwnerServiceSrv.Iface rpcMetaClientToNoMetaSrv = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), Arrays.asList(IntExtension.instance), getUrlString("/rpc_no_cmeta"));
OwnerServiceSrv.Iface rpcNoMetaClientToMetaSrv = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), getUrlString("/rpc_cmeta"));
OwnerServiceSrv.Iface client1 = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), getUrlString("/rpc_no_cmeta"));
OwnerServiceSrv.Iface client2 = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), getUrlString("/rpc_no_cmeta"));
OwnerServiceSrv.Iface client3 = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), getUrlString("/rpc_no_cmeta"));
OwnerServiceSrv.Iface rpcMetaClientToMetaSrv = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), Arrays.asList(IntExtension.instance), getUrlString("/rpc_cmeta"));
OwnerServiceSrv.Iface rpcMetaClientToNoMetaSrv = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), Arrays.asList(IntExtension.instance), getUrlString("/rpc_no_cmeta"));
OwnerServiceSrv.Iface rpcNoMetaClientToMetaSrv = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), getUrlString("/rpc_cmeta"));
OwnerServiceSrv.Iface rpcNoMetaClientToNoMetaSrv = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), getUrlString("/rpc_no_cmeta"));
OwnerServiceSrv.Iface client1 = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), getUrlString("/rpc_no_cmeta"));
OwnerServiceSrv.Iface client2 = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), getUrlString("/rpc_no_cmeta"));
OwnerServiceSrv.Iface client3 = createThriftRPCClient(OwnerServiceSrv.Iface.class, new TimestampIdGenerator(), new CompositeClientEventListener(), getUrlString("/rpc_no_cmeta"));
Servlet cMetaServlet = createThriftRPCService(OwnerServiceSrv.Iface.class, handler, new CompositeServiceEventListener(), Arrays.asList(IntExtension.instance));
Servlet ncMetaServlet = createThriftRPCService(OwnerServiceSrv.Iface.class, handler, new CompositeServiceEventListener());
@ -134,6 +138,21 @@ public class TestCustomMetadataExtension extends AbstractTest {
}).run();
}
@Test
public void testCustomExtensionWithDotSymbol() {
addServlet(ncMetaServlet, "/rpc_no_cmeta");
new WFlow().createServiceFork(() -> {
ContextUtils.setCustomMetadataValue("test.test.test", "test");
try {
rpcNoMetaClientToNoMetaSrv.getOwner(11);
} catch (TException e) {
e.printStackTrace();
fail();
}
}).run();
}
@Test
public void testCustomExtensionNoData() {
addServlet(cMetaServlet, "/rpc_cmeta");