Skip to content

Commit

Permalink
Merge a31b494 into 485478e
Browse files Browse the repository at this point in the history
  • Loading branch information
weichao666 committed Jan 8, 2018
2 parents 485478e + a31b494 commit 26d7f8c
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@ public interface ServiceCombConstants {
String CONFIG_CSE_PREFIX = "cse.";

String CONFIG_KEY_SPLITER = "_";

String CONFIG_FRAMEWORK_DEFAULT_NAME = "servicecomb-java-chassis";

String CONFIG_FRAMEWORK_DEFAULT_VERSION = "1.0";

String CONFIG_DEFAULT_REGISTER_BY = "SDK";

}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@ public static final class REGISTRY_API {
public static final String PATH_CHECKSESSION = "checksession";

public static final String URL_PREFIX = "urlPrefix";

public static final String INSTANCE_PUBKEY_PRO = "publickey";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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 io.servicecomb.serviceregistry.api.registry;

/**
* Created by on 2017/12/20.
*/
public class Framework {
private String name;

private String version;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
public class Microservice {
private String serviceId;

private Framework framework;

private String registerBy;

private String appId;

private String serviceName;
Expand Down Expand Up @@ -189,4 +193,20 @@ public List<BasePath> getPaths() {
public void setPaths(List<BasePath> paths) {
this.paths = paths;
}

public Framework getFramework() {
return framework;
}

public void setFramework(Framework framework) {
this.framework = framework;
}

public String getRegisterBy() {
return registerBy;
}

public void setRegisterBy(String registerBy) {
this.registerBy = registerBy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_NAME_KEY;
import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_ROLE_KEY;
import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_QUALIFIED_MICROSERVICE_VERSION_KEY;
import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_FRAMEWORK_DEFAULT_NAME;
import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_FRAMEWORK_DEFAULT_VERSION;
import static io.servicecomb.foundation.common.base.ServiceCombConstants.CONFIG_DEFAULT_REGISTER_BY;
import static io.servicecomb.foundation.common.base.ServiceCombConstants.DEFAULT_MICROSERVICE_NAME;
import static io.servicecomb.serviceregistry.definition.DefinitionConst.CONFIG_ALLOW_CROSS_APP_KEY;
import static io.servicecomb.serviceregistry.definition.DefinitionConst.DEFAULT_APPLICATION_ID;
Expand Down Expand Up @@ -66,6 +69,13 @@ private Microservice createMicroserviceFromDefinition(Configuration configuratio
microservice.getServiceName()));
}

// use default values, we can add configure item in future.
Framework framework = new Framework();
framework.setName(CONFIG_FRAMEWORK_DEFAULT_NAME);
framework.setVersion(CONFIG_FRAMEWORK_DEFAULT_VERSION);
microservice.setFramework(framework);
microservice.setRegisterBy(CONFIG_DEFAULT_REGISTER_BY);

return microservice;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 io.servicecomb.serviceregistry.api.registry;

import org.junit.Assert;
import org.junit.Test;

public class TestFramework {
@Test
public void testDefaultValues() {
Framework framework = new Framework();
Assert.assertNull(framework.getName());
Assert.assertNull(framework.getVersion());
}

@Test
public void testInitializedValues() {
Framework framework = new Framework();
framework.setName("JAVA-CHASSIS");
framework.setVersion("x.x.x");
Assert.assertEquals("JAVA-CHASSIS", framework.getName());
Assert.assertEquals("x.x.x", framework.getVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void testDefaultValues() {
Assert.assertEquals(MicroserviceInstanceStatus.UP.toString(), oMicroservice.getStatus());
Assert.assertNull(oMicroservice.getVersion());
Assert.assertEquals(0, oMicroservice.getPaths().size());
Assert.assertNull(oMicroservice.getFramework());
}

@Test
Expand All @@ -76,6 +77,9 @@ public void testInitializedValues() {
Assert.assertEquals("fakeProxy", oMicroservice.getProperties().get("proxy"));
Assert.assertEquals(1, oMicroservice.getSchemas().size());
Assert.assertEquals(1, oMicroservice.getPaths().size());
Assert.assertEquals("JAVA-CHASSIS", oMicroservice.getFramework().getName());
Assert.assertEquals("x.x.x", oMicroservice.getFramework().getVersion());
Assert.assertEquals("SDK", oMicroservice.getRegisterBy());
}

private void initMicroservice() {
Expand All @@ -91,5 +95,10 @@ private void initMicroservice() {
oMicroservice.setProperties(oMapProperties);
oMicroservice.setSchemas(oListSchemas);
oMicroservice.getPaths().add(new BasePath());
Framework framework = new Framework();
framework.setName("JAVA-CHASSIS");
framework.setVersion("x.x.x");
oMicroservice.setFramework(framework);
oMicroservice.setRegisterBy("SDK");
}
}

0 comments on commit 26d7f8c

Please sign in to comment.