Skip to content

Commit 41fd242

Browse files
authored
Adjust to core changes (addon.xml) (#444)
Signed-off-by: Jan N. Klug <github@klug.nrw>
1 parent 6267a34 commit 41fd242

12 files changed

Lines changed: 46 additions & 44 deletions

File tree

custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlLabelCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected void checkConfigFile(final FileText xmlFileText) throws CheckstyleExce
118118
}
119119

120120
@Override
121-
protected void checkBindingFile(final FileText xmlFileText) throws CheckstyleException {
121+
protected void checkAddonFile(final FileText xmlFileText) throws CheckstyleException {
122122
// No labels in binding files.
123123
}
124124

custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlUsageCheck.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ protected void checkConfigFile(final FileText xmlFileText) throws CheckstyleExce
8787
}
8888

8989
@Override
90-
protected void checkBindingFile(final FileText xmlFileText) throws CheckstyleException {
91-
// The allowed values are described in the binding XSD
90+
protected void checkAddonFile(final FileText xmlFileText) throws CheckstyleException {
91+
// The allowed values are described in the addon XSD
9292
allConfigDescriptionRefs.putAll(evaluateExpressionOnFile(xmlFileText, CONFIG_DESCRIPTION_REF_EXPRESSION));
9393
allConfigDescriptions.putAll(evaluateExpressionOnFile(xmlFileText, CONFIG_DESCRIPTION_EXPRESSION));
9494
}

custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/OhInfXmlValidationCheck.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public class OhInfXmlValidationCheck extends AbstractOhInfXmlCheck {
5454
private Map<Path, File> ohInfFiles = new HashMap<>();
5555

5656
private String thingSchema;
57-
private String bindingSchema;
57+
private String addonSchema;
5858
private String configSchema;
5959

6060
private static Schema thingSchemaFile;
61-
private static Schema bindingSchemaFile;
61+
private static Schema addonSchemaFile;
6262
private static Schema configSchemaFile;
6363

6464
/**
@@ -73,10 +73,10 @@ public void setThingSchema(String thingSchema) {
7373
/**
7474
* Sets the configuration property for the binding schema file.
7575
*
76-
* @param bindingSchema URL of the binding schema file
76+
* @param addonSchema URL of the binding schema file
7777
*/
78-
public void setBindingSchema(String bindingSchema) {
79-
this.bindingSchema = bindingSchema;
78+
public void setAddonSchema(String addonSchema) {
79+
this.addonSchema = addonSchema;
8080
}
8181

8282
/**
@@ -111,7 +111,7 @@ public Schema transform(byte[] content) {
111111

112112
CachingHttpClient<Schema> cachingClient = new CachingHttpClient<>(callback);
113113

114-
bindingSchemaFile = getXSD(bindingSchema, cachingClient);
114+
addonSchemaFile = getXSD(addonSchema, cachingClient);
115115
thingSchemaFile = getXSD(thingSchema, cachingClient);
116116
configSchemaFile = getXSD(configSchema, cachingClient);
117117

@@ -126,10 +126,10 @@ protected void checkConfigFile(FileText xmlFileText) throws CheckstyleException
126126
}
127127

128128
@Override
129-
protected void checkBindingFile(FileText xmlFileText) throws CheckstyleException {
129+
protected void checkAddonFile(FileText xmlFileText) throws CheckstyleException {
130130
File xmlFile = xmlFileText.getFile();
131131
addToOhFiles(xmlFile);
132-
validateXmlAgainstSchema(xmlFile, bindingSchemaFile);
132+
validateXmlAgainstSchema(xmlFile, addonSchemaFile);
133133
}
134134

135135
@Override

custom-checks/checkstyle/src/main/java/org/openhab/tools/analysis/checkstyle/api/AbstractOhInfXmlCheck.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939
public abstract class AbstractOhInfXmlCheck extends AbstractStaticCheck {
4040
public static final String THING_DIRECTORY = "thing";
41-
public static final String BINDING_DIRECTORY = "binding";
41+
public static final String ADDON_DIRECTORY = "addon";
4242
public static final String CONFIGURATION_DIRECTORY = "config";
4343

4444
private static final String MESSAGE_EMPTY_FILE = "The file {0} should not be empty.";
@@ -77,8 +77,8 @@ private void processXmlFile(final FileText xmlFileText) throws CheckstyleExcepti
7777
checkThingTypeFile(xmlFileText);
7878
break;
7979
}
80-
case BINDING_DIRECTORY: {
81-
checkBindingFile(xmlFileText);
80+
case ADDON_DIRECTORY: {
81+
checkAddonFile(xmlFileText);
8282
break;
8383
}
8484
case CONFIGURATION_DIRECTORY: {
@@ -108,7 +108,7 @@ private void processXmlFile(final FileText xmlFileText) throws CheckstyleExcepti
108108
* @param xmlFileText Represents the text contents of the xml file
109109
* @throws CheckstyleException when exception occurred during XML processing
110110
*/
111-
protected abstract void checkBindingFile(FileText xmlFileText) throws CheckstyleException;
111+
protected abstract void checkAddonFile(FileText xmlFileText) throws CheckstyleException;
112112

113113
/**
114114
* Validate a .xml file located in the OH-INF/thing directory

custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OhInfXmlValidationCheckTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ public class OhInfXmlValidationCheckTest extends AbstractStaticCheckTest {
4242

4343
private static final String RELATIVE_PATH_TO_THING = File.separator + OH_INF_PATH + File.separator
4444
+ OhInfXmlValidationCheck.THING_DIRECTORY + File.separator + "thing-types.xml";
45-
private static final String RELATIVE_PATH_TO_BINDING = File.separator + OH_INF_PATH + File.separator
46-
+ OhInfXmlValidationCheck.BINDING_DIRECTORY + File.separator + "bind.xml";
45+
private static final String RELATIVE_PATH_TO_ADDON = File.separator + OH_INF_PATH + File.separator
46+
+ OhInfXmlValidationCheck.ADDON_DIRECTORY + File.separator + "addon.xml";
4747
private static final String RELATIVE_PATH_TO_CONFIG = File.separator + OH_INF_PATH + File.separator
4848
+ OhInfXmlValidationCheck.CONFIGURATION_DIRECTORY + File.separator + "conf.xml";
4949

5050
private static final String SCHEMA_ROOT_URL = "https://openhab.org/schemas/";
5151
private static final String THING_SCHEMA_URL = SCHEMA_ROOT_URL + "thing-description-1.0.0.xsd";
52-
private static final String BINDING_SCHEMA_URL = SCHEMA_ROOT_URL + "binding-1.0.0.xsd";
52+
private static final String ADDON_SCHEMA_URL = SCHEMA_ROOT_URL + "addon-1.0.0.xsd";
5353
private static final String CONFIG_SCHEMA_URL = SCHEMA_ROOT_URL + "config-description-1.0.0.xsd";
5454

5555
private static final String MESSAGE_EMPTY_FILE = "The file {0} should not be empty.";
@@ -59,7 +59,7 @@ public class OhInfXmlValidationCheckTest extends AbstractStaticCheckTest {
5959
@BeforeAll
6060
public static void createConfiguration() {
6161
CONFIGURATION.addProperty("thingSchema", THING_SCHEMA_URL);
62-
CONFIGURATION.addProperty("bindingSchema", BINDING_SCHEMA_URL);
62+
CONFIGURATION.addProperty("addonSchema", ADDON_SCHEMA_URL);
6363
CONFIGURATION.addProperty("configSchema", CONFIG_SCHEMA_URL);
6464
}
6565

@@ -157,13 +157,13 @@ public void testValidBridgeType() throws Exception {
157157
}
158158

159159
@Test
160-
public void testInvalidBinding() throws Exception {
160+
public void testInvalidAddon() throws Exception {
161161
assumeTrue(isResourceAvailable);
162162

163163
int lineNumber = 7;
164164
String[] expectedMessages = generateExpectedMessages(lineNumber,
165-
"The content of element binding:binding is not complete. One of {name} is expected.");
166-
verifyWithPath("invalidBinding", RELATIVE_PATH_TO_BINDING, expectedMessages);
165+
"The content of element addon:addon is not complete. One of {type} is expected.");
166+
verifyWithPath("invalidAddon", RELATIVE_PATH_TO_ADDON, expectedMessages);
167167
}
168168

169169
@Test

custom-checks/checkstyle/src/test/java/org/openhab/tools/analysis/checkstyle/test/OnlyTabIndentationCheckTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void testXmlWithMultipleLinesWithSpacesEmptyLinesAndComments() throws Exc
9797

9898
@Test
9999
public void testXmlWithOnlyTabsForIndentation() throws Exception {
100-
String fileName = "binding.xml";
100+
String fileName = "addon.xml";
101101
verifyTabIdentation(fileName, noMessagesExpected(), false);
102102
}
103103

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<addon:addon id="bindingID" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:addon="https://openhab.org/schemas/addon/v1.0.0"
3+
xsi:schemaLocation="https://openhab.org/schemas/addon/v1.0.0
4+
https://openhab.org/schemas/addon-1.0.0.xsd">
5+
6+
7+
</addon:addon>

custom-checks/checkstyle/src/test/resources/checkstyle/ohInfXmlValidationCheckTest/invalidBinding/src/main/resources/OH-INF/binding/bind.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<binding:binding id="bindingID" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
3-
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0
4-
https://openhab.org/schemas/binding-1.0.0.xsd">
2+
<addon:addon id="bindingID" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:addon="https://openhab.org/schemas/addon/v1.0.0"
3+
xsi:schemaLocation="https://openhab.org/schemas/addon/v1.0.0
4+
https://openhab.org/schemas/addon-1.0.0.xsd">
55

6+
<type>binding</type>
67
<name>String</name>
78
<description>String</description>
89
<author>String</author>
910

1011
<config-description-ref uri="binding:bindingID:bind" />
1112

12-
</binding:binding>
13+
</addon:addon>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<addon:addon id="onewiregpio" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:addon="https://openhab.org/schemas/addon/v1.0.0"
3+
xsi:schemaLocation="https://openhab.org/schemas/addon/v1.0.0 https://openhab.org/schemas/addon-1.0.0.xsd">
4+
<type>binding</type>
5+
<name>OneWireGPIO Binding</name>
6+
<description>Use GPIO in various devices like RaspberryPi to communicate the OneWire protocol</description>
7+
<author>Anatol Ogorek</author>
8+
</addon:addon>

0 commit comments

Comments
 (0)