use of com.sldeditor.common.vendoroption.VersionData in project sldeditor by robward-scisys.
the class GeoServerVendorOptionTest method testGetVersionStringList.
/**
* Test method for {@link com.sldeditor.common.vendoroption.GeoServerVendorOption#getVersionStringList()}.
* Test method for {@link com.sldeditor.common.vendoroption.GeoServerVendorOption#addVersion(com.sldeditor.common.vendoroption.VersionData)}.
* Test method for {@link com.sldeditor.common.vendoroption.GeoServerVendorOption#getVersion(java.lang.String)}.
* Test method for {@link com.sldeditor.common.vendoroption.GeoServerVendorOption#getVersionList()}.
*/
@Test
public void testGetVersionStringList() {
GeoServerVendorOption vendorOption = new GeoServerVendorOption();
assertEquals(0, vendorOption.getVersionStringList().size());
assertEquals(0, vendorOption.getVersionList().size());
// This should be ignored
vendorOption.addVersion(null);
assertEquals(0, vendorOption.getVersionStringList().size());
assertEquals(0, vendorOption.getVersionList().size());
VersionData versionData1 = new VersionData();
vendorOption.addVersion(versionData1);
assertEquals(1, vendorOption.getVersionStringList().size());
assertEquals(1, vendorOption.getVersionList().size());
VersionData versionData2 = new VersionData();
vendorOption.addVersion(versionData2);
assertEquals(2, vendorOption.getVersionStringList().size());
assertEquals(2, vendorOption.getVersionList().size());
List<VersionData> voList = vendorOption.getVersionList();
assertEquals(versionData1, voList.get(0));
assertEquals(versionData2, voList.get(1));
List<String> voStringList = vendorOption.getVersionStringList();
assertEquals(versionData1.getVersionString(), voStringList.get(0));
assertEquals(versionData2.getVersionString(), voStringList.get(1));
}
use of com.sldeditor.common.vendoroption.VersionData in project sldeditor by robward-scisys.
the class VendorOptionManagerTest method testGetTitle.
/**
* Test method for {@link com.sldeditor.common.vendoroption.VendorOptionManager#getTitle()}.
*/
@Test
public void testGetTitle() {
StringBuilder expectedValue = new StringBuilder();
expectedValue.append("- ");
expectedValue.append(Localisation.getString(ParseXML.class, "ParseXML.vendorOption"));
expectedValue.append(" ");
String actualValue = VendorOptionManager.getInstance().getTitle(null);
assertTrue(expectedValue.toString().compareTo(actualValue) == 0);
// Now try with some real values
VersionData noVO = VersionData.getDecodedString("com.sldeditor.common.vendoroption.NoVendorOption@Latest");
VendorOptionVersion noVOV = new VendorOptionVersion(NoVendorOption.class, noVO);
actualValue = VendorOptionManager.getInstance().getTitle(noVOV);
StringBuilder expectedValue1 = new StringBuilder();
expectedValue1.append(expectedValue.toString());
expectedValue1.append("(Strict SLD Latest)");
assertTrue(expectedValue1.toString().compareTo(actualValue) == 0);
VersionData geoServerVOMin = VersionData.getDecodedString("com.sldeditor.common.vendoroption.GeoServerVendorOption@2.4.2");
VersionData geoServerVOMax = VersionData.getDecodedString("com.sldeditor.common.vendoroption.GeoServerVendorOption@2.9.0");
VendorOptionVersion geoServerVOV = new VendorOptionVersion(GeoServerVendorOption.class, geoServerVOMin, geoServerVOMax);
actualValue = VendorOptionManager.getInstance().getTitle(geoServerVOV);
StringBuilder expectedValue2 = new StringBuilder();
expectedValue2.append(expectedValue.toString());
expectedValue2.append("(GeoServer 2.4.2-2.9.0)");
assertTrue(expectedValue2.toString().compareTo(actualValue) == 0);
}
use of com.sldeditor.common.vendoroption.VersionData in project sldeditor by robward-scisys.
the class VendorOptionManagerTest method testLoadSLDFile.
/**
* Test method for {@link com.sldeditor.common.vendoroption.VendorOptionManager#getVendorOptionVersion()}.
*/
@Test
public void testLoadSLDFile() {
VendorOptionManager.destroyInstance();
PrefData prefData = PrefManager.getInstance().getPrefData();
List<VersionData> vendorOptionList = new ArrayList<VersionData>();
VersionData actualPrefVO = VersionData.decode(GeoServerVendorOption.class, "2.4.2");
vendorOptionList.add(actualPrefVO);
prefData.setVendorOptionVersionList(vendorOptionList);
PrefManager.getInstance().setPrefData(prefData);
SLDData sldData = new SLDData(null, null);
StyledLayerDescriptor sld = null;
VendorOptionManager.getInstance().addVendorOptionListener(obj);
obj.vendorOptionVersionsList.clear();
// No SLD Editor file, SLD is empty so it should you PrefManager default set above
VendorOptionManager.getInstance().loadSLDFile(null, sld, sldData);
assertEquals(1, obj.vendorOptionVersionsList.size());
assertEquals(actualPrefVO, obj.vendorOptionVersionsList.get(0));
// No SLD Editor file, SLD contains PointSymboliser with vendor
// option so it should use the SLD vendor option
obj.vendorOptionVersionsList.clear();
sld = DefaultSymbols.createNewSLD();
SelectedSymbol.getInstance().createNewSLD(sld);
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
String expectedNameLayerValue = "named layer test value";
namedLayer.setName(expectedNameLayerValue);
Style style = DefaultSymbols.createNewStyle();
String expectedNameStyleValue = "style test value";
style.setName(expectedNameStyleValue);
namedLayer.addStyle(style);
FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
String expectedNameFTSValue = "feature type style test value";
fts.setName(expectedNameFTSValue);
style.featureTypeStyles().add(fts);
Rule rule = DefaultSymbols.createNewRule();
String expectedNameValue = "rule test value";
rule.setName(expectedNameValue);
PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer();
rule.symbolizers().add(symbolizer);
fts.rules().add(rule);
sld.layers().add(namedLayer);
VersionData testVersionData = VersionData.decode(GeoServerVendorOption.class, "2.8.0");
VendorOptionManager.getInstance().loadSLDFile(new GetMinimumVersionInterface() {
@Override
public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
VendorOptionInfo vendorOptionInfo = new VendorOptionInfo("qgis://", new VendorOptionVersion(testVersionData.getVendorOptionType(), testVersionData), "");
VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, vendorOptionInfo);
vendorOptionsPresentList.add(voPresent);
}
}, sld, sldData);
assertEquals(1, obj.vendorOptionVersionsList.size());
assertEquals(testVersionData, obj.vendorOptionVersionsList.get(0));
// Now set the SLD Editor file vendor option
obj.vendorOptionVersionsList.clear();
List<VersionData> sldEditorVendorOptionList = new ArrayList<VersionData>();
VersionData testVersionData2 = VersionData.decode(GeoServerVendorOption.class, "2.10.0");
sldEditorVendorOptionList.add(testVersionData2);
sldEditorVendorOptionList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData());
sldData.setVendorOptionList(sldEditorVendorOptionList);
sldData.setSldEditorFile(new File("."));
VendorOptionManager.getInstance().loadSLDFile(new GetMinimumVersionInterface() {
@Override
public void getMinimumVersion(Object parentObj, Object sldObj, List<VendorOptionPresent> vendorOptionsPresentList) {
VendorOptionInfo vendorOptionInfo = new VendorOptionInfo("qgis://", new VendorOptionVersion(testVersionData.getVendorOptionType(), testVersionData), "");
VendorOptionPresent voPresent = new VendorOptionPresent(sldObj, vendorOptionInfo);
vendorOptionsPresentList.add(voPresent);
}
}, sld, sldData);
Collections.sort(obj.vendorOptionVersionsList);
assertEquals(2, obj.vendorOptionVersionsList.size());
assertEquals(testVersionData2, obj.vendorOptionVersionsList.get(obj.vendorOptionVersionsList.size() - 1));
// Increase code coverage
VendorOptionManager.getInstance().loadSLDFile(null, null, null);
}
use of com.sldeditor.common.vendoroption.VersionData in project sldeditor by robward-scisys.
the class VendorOptionVersionTest method testVendorOptionVersionClassOfQVersionData.
/**
* Test method for {@link com.sldeditor.common.vendoroption.VendorOptionVersion#VendorOptionVersion(java.lang.Class, com.sldeditor.common.vendoroption.VersionData)}.
*/
@Test
public void testVendorOptionVersionClassOfQVersionData() {
VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
VendorOptionVersion vo = new VendorOptionVersion(getClass(), versionDataMin);
assertEquals(versionDataMin, vo.getLatest());
}
use of com.sldeditor.common.vendoroption.VersionData in project sldeditor by robward-scisys.
the class VendorOptionVersionTest method testFromString.
/**
* Test method for {@link com.sldeditor.common.vendoroption.VendorOptionVersion#fromString(java.lang.String)}.
* Test method for {@link com.sldeditor.common.vendoroption.VendorOptionVersion#toString()}.
*/
@Test
public void testFromString() {
VersionData versionDataMin = VersionData.decode(getClass(), "2.4.1");
VersionData versionDataMax = VersionData.decode(getClass(), "2.8.3");
VendorOptionVersion vo = new VendorOptionVersion(getClass(), versionDataMin, versionDataMax);
String actualString = vo.toString();
VendorOptionVersion decoded = VendorOptionVersion.fromString(actualString);
assertEquals(vo.getLatest(), decoded.getLatest());
assertEquals(vo.toString(), decoded.toString());
}
Aggregations