Repository: curator Updated Branches: refs/heads/CURATOR-394 6f3b178fd -> e7f55f890
rename NewServiceInstance to make it clear it's only for testing Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/e7f55f89 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/e7f55f89 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/e7f55f89 Branch: refs/heads/CURATOR-394 Commit: e7f55f89056f1447cb2ed73a0cdfd66759e11f91 Parents: 6f3b178 Author: randgalt <randg...@apache.org> Authored: Fri Mar 31 13:25:04 2017 -0500 Committer: randgalt <randg...@apache.org> Committed: Fri Mar 31 13:25:04 2017 -0500 ---------------------------------------------------------------------- .../x/discovery/details/NewServiceInstance.java | 148 ------------------- ...TestJsonInstanceSerializerCompatibility.java | 2 +- .../details/TestNewServiceInstance.java | 145 ++++++++++++++++++ 3 files changed, 146 insertions(+), 149 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/e7f55f89/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/NewServiceInstance.java ---------------------------------------------------------------------- diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/NewServiceInstance.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/NewServiceInstance.java deleted file mode 100644 index 407ce6f..0000000 --- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/NewServiceInstance.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.curator.x.discovery.details; - -import com.google.common.base.Preconditions; -import org.apache.curator.x.discovery.ServiceType; -import org.apache.curator.x.discovery.UriSpec; -import org.codehaus.jackson.annotate.JsonTypeInfo; -import org.codehaus.jackson.annotate.JsonTypeInfo.Id; -import java.net.URI; -import java.util.Date; - -/** - * POJO that represents a service instance - */ -class NewServiceInstance<T> -{ - private final String name; - private final String id; - private final String address; - private final Integer port; - private final Integer sslPort; - private final T payload; - private final long registrationTimeUTC; - private final ServiceType serviceType; - private final UriSpec uriSpec; - private final boolean enabled; - private final String new1; - private final Long new2; - private final Date new3; - private final URI new4; - - public NewServiceInstance(String name, String id, String address, Integer port, Integer sslPort, T payload, long registrationTimeUTC, ServiceType serviceType, UriSpec uriSpec, boolean enabled, String new1, Long new2, Date new3, URI new4) - { - name = Preconditions.checkNotNull(name, "name cannot be null"); - id = Preconditions.checkNotNull(id, "id cannot be null"); - - this.new1 = new1; - this.new2 = new2; - this.new3 = new3; - this.new4 = new4; - this.serviceType = serviceType; - this.uriSpec = uriSpec; - this.name = name; - this.id = id; - this.address = address; - this.port = port; - this.sslPort = sslPort; - this.payload = payload; - this.registrationTimeUTC = registrationTimeUTC; - this.enabled = enabled; - } - - /** - * Inits to default values. Only exists for deserialization - */ - NewServiceInstance() - { - this("", "", null, null, null, null, 0, ServiceType.DYNAMIC, null, true, null, null, null, null); - } - - public String getName() - { - return name; - } - - public String getId() - { - return id; - } - - public String getAddress() - { - return address; - } - - public Integer getPort() - { - return port; - } - - public Integer getSslPort() - { - return sslPort; - } - - @JsonTypeInfo(use = Id.CLASS, defaultImpl = Object.class) - public T getPayload() - { - return payload; - } - - public long getRegistrationTimeUTC() - { - return registrationTimeUTC; - } - - public ServiceType getServiceType() - { - return serviceType; - } - - public UriSpec getUriSpec() - { - return uriSpec; - } - - public boolean isEnabled() - { - return enabled; - } - - public String getNew1() - { - return new1; - } - - public Long getNew2() - { - return new2; - } - - public Date getNew3() - { - return new3; - } - - public URI getNew4() - { - return new4; - } -} http://git-wip-us.apache.org/repos/asf/curator/blob/e7f55f89/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestJsonInstanceSerializerCompatibility.java ---------------------------------------------------------------------- diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestJsonInstanceSerializerCompatibility.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestJsonInstanceSerializerCompatibility.java index 41674b2..6ac19c2 100644 --- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestJsonInstanceSerializerCompatibility.java +++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestJsonInstanceSerializerCompatibility.java @@ -75,7 +75,7 @@ public class TestJsonInstanceSerializerCompatibility @Test public void testFutureChanges() throws Exception { - NewServiceInstance<String> newInstance = new NewServiceInstance<String>("name", "id", "address", 10, 20, "hey", 0, ServiceType.DYNAMIC, new UriSpec("{a}/b/{c}"), false, "what", 10101L, new Date(), new URI("http://hey")); + TestNewServiceInstance<String> newInstance = new TestNewServiceInstance<String>("name", "id", "address", 10, 20, "hey", 0, ServiceType.DYNAMIC, new UriSpec("{a}/b/{c}"), false, "what", 10101L, new Date(), new URI("http://hey")); byte[] newInstanceBytes = new ObjectMapper().writeValueAsBytes(newInstance); JsonInstanceSerializer<String> serializer = new JsonInstanceSerializer<String>(String.class); ServiceInstance<String> instance = serializer.deserialize(newInstanceBytes); http://git-wip-us.apache.org/repos/asf/curator/blob/e7f55f89/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestNewServiceInstance.java ---------------------------------------------------------------------- diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestNewServiceInstance.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestNewServiceInstance.java new file mode 100644 index 0000000..e627474 --- /dev/null +++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestNewServiceInstance.java @@ -0,0 +1,145 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.x.discovery.details; + +import com.google.common.base.Preconditions; +import org.apache.curator.x.discovery.ServiceType; +import org.apache.curator.x.discovery.UriSpec; +import org.codehaus.jackson.annotate.JsonTypeInfo; +import org.codehaus.jackson.annotate.JsonTypeInfo.Id; +import java.net.URI; +import java.util.Date; + +class TestNewServiceInstance<T> +{ + private final String name; + private final String id; + private final String address; + private final Integer port; + private final Integer sslPort; + private final T payload; + private final long registrationTimeUTC; + private final ServiceType serviceType; + private final UriSpec uriSpec; + private final boolean enabled; + private final String new1; + private final Long new2; + private final Date new3; + private final URI new4; + + public TestNewServiceInstance(String name, String id, String address, Integer port, Integer sslPort, T payload, long registrationTimeUTC, ServiceType serviceType, UriSpec uriSpec, boolean enabled, String new1, Long new2, Date new3, URI new4) + { + name = Preconditions.checkNotNull(name, "name cannot be null"); + id = Preconditions.checkNotNull(id, "id cannot be null"); + + this.new1 = new1; + this.new2 = new2; + this.new3 = new3; + this.new4 = new4; + this.serviceType = serviceType; + this.uriSpec = uriSpec; + this.name = name; + this.id = id; + this.address = address; + this.port = port; + this.sslPort = sslPort; + this.payload = payload; + this.registrationTimeUTC = registrationTimeUTC; + this.enabled = enabled; + } + + /** + * Inits to default values. Only exists for deserialization + */ + TestNewServiceInstance() + { + this("", "", null, null, null, null, 0, ServiceType.DYNAMIC, null, true, null, null, null, null); + } + + public String getName() + { + return name; + } + + public String getId() + { + return id; + } + + public String getAddress() + { + return address; + } + + public Integer getPort() + { + return port; + } + + public Integer getSslPort() + { + return sslPort; + } + + @JsonTypeInfo(use = Id.CLASS, defaultImpl = Object.class) + public T getPayload() + { + return payload; + } + + public long getRegistrationTimeUTC() + { + return registrationTimeUTC; + } + + public ServiceType getServiceType() + { + return serviceType; + } + + public UriSpec getUriSpec() + { + return uriSpec; + } + + public boolean isEnabled() + { + return enabled; + } + + public String getNew1() + { + return new1; + } + + public Long getNew2() + { + return new2; + } + + public Date getNew3() + { + return new3; + } + + public URI getNew4() + { + return new4; + } +}