use of com.serotonin.json.type.JsonValue in project ma-core-public by infiniteautomation.
the class StoreLatestProductionTest method testThreeTwoReleaseVersion.
// @Test
public void testThreeTwoReleaseVersion() throws JsonException, IOException, HttpException {
// Setup json
json.put("upgradeVersionState", UpgradeVersionState.PRODUCTION);
json.put("currentVersionState", UpgradeVersionState.PRODUCTION);
jsonModules.put("core", "3.2.0");
jsonModules.put("mangoApi", "3.2.0");
String url = baseUrl + "/servlet/versionCheck";
HttpPost post = new HttpPost(url);
StringWriter stringWriter = new StringWriter();
new JsonWriter(JSON_CONTEXT, stringWriter).writeObject(json);
String requestData = stringWriter.toString();
post.setEntity(new StringEntity(requestData));
String responseData = HttpUtils4.getTextContent(getHttpClient(30000), post, 1);
JsonTypeReader jsonReader = new JsonTypeReader(responseData);
JsonValue response = jsonReader.read();
printResponse(response);
Assert.assertNotNull(response.getJsonValue("versionState"));
Assert.assertEquals("PRODUCTION", response.getJsonValue("versionState").toString());
// Assert newInstalls-oldCore should be empty
Assert.assertNotNull(response.getJsonValue("newInstalls-oldCore"));
JsonArray newInstallsOldCore = response.getJsonValue("newInstalls-oldCore").toJsonArray();
Assert.assertEquals(true, newInstallsOldCore.size() == 0);
// Assert update-versionState
Assert.assertNull(response.getJsonValue("update-versionState"));
// Assert updates for this core iff major upgrade available
Assert.assertNotNull(response.getJsonValue("updates"));
JsonArray updates = response.getJsonValue("updates").toJsonArray();
Assert.assertEquals(true, updates.size() == 0);
// Assert upgrades
Assert.assertNotNull(response.getJsonValue("upgrades"));
JsonArray upgrades = response.getJsonValue("upgrades").toJsonArray();
Assert.assertEquals(true, upgrades.size() == 2);
for (JsonValue upgrade : upgrades) {
Assert.assertEquals(true, upgrade.getJsonValue("fullVersion").toString().startsWith(latestProductionCorePrefix));
}
// Assert newInstalls should be for latest production core
Assert.assertNotNull(response.getJsonValue("newInstalls"));
JsonArray newInstalls = response.getJsonValue("newInstalls").toJsonArray();
Assert.assertEquals(true, newInstalls.size() > 0);
for (JsonValue install : newInstalls) {
Assert.assertEquals(true, install.getJsonValue("fullVersion").toString().startsWith(latestProductionCorePrefix));
}
}
use of com.serotonin.json.type.JsonValue in project ma-core-public by infiniteautomation.
the class StoreLatestProductionTest method testThreeTwoPreviousDevelopmentVersion.
// @Test
public void testThreeTwoPreviousDevelopmentVersion() throws JsonException, IOException, HttpException {
// Setup json
json.put("upgradeVersionState", UpgradeVersionState.DEVELOPMENT);
json.put("currentVersionState", UpgradeVersionState.DEVELOPMENT);
jsonModules.put("core", "3.2.2-SNAPSHOT");
jsonModules.put("mangoApi", "3.2.3-SNAPSHOT");
String url = baseUrl + "/servlet/versionCheck";
HttpPost post = new HttpPost(url);
StringWriter stringWriter = new StringWriter();
new JsonWriter(JSON_CONTEXT, stringWriter).writeObject(json);
String requestData = stringWriter.toString();
post.setEntity(new StringEntity(requestData));
String responseData = HttpUtils4.getTextContent(getHttpClient(30000), post, 1);
JsonTypeReader jsonReader = new JsonTypeReader(responseData);
JsonValue response = jsonReader.read();
printResponse(response);
Assert.assertNotNull(response.getJsonValue("versionState"));
Assert.assertEquals("PRODUCTION", response.getJsonValue("versionState").toString());
// Assert newInstalls-oldCore should be empty
Assert.assertNotNull(response.getJsonValue("newInstalls-oldCore"));
JsonArray newInstallsOldCore = response.getJsonValue("newInstalls-oldCore").toJsonArray();
Assert.assertEquals(true, newInstallsOldCore.size() == 0);
// Assert update-versionState
Assert.assertNull(response.getJsonValue("update-versionState"));
// Assert updates for this core iff major upgrade available
Assert.assertNotNull(response.getJsonValue("updates"));
JsonArray updates = response.getJsonValue("updates").toJsonArray();
Assert.assertEquals(true, updates.size() == 0);
// Assert upgrades
Assert.assertNotNull(response.getJsonValue("upgrades"));
JsonArray upgrades = response.getJsonValue("upgrades").toJsonArray();
Assert.assertEquals(true, upgrades.size() > 0);
for (JsonValue upgrade : upgrades) {
Assert.assertEquals(true, upgrade.getJsonValue("fullVersion").toString().startsWith(latestProductionCorePrefix));
}
// Assert newInstalls should be for latest production core
Assert.assertNotNull(response.getJsonValue("newInstalls"));
JsonArray newInstalls = response.getJsonValue("newInstalls").toJsonArray();
Assert.assertEquals(true, newInstalls.size() > 0);
for (JsonValue install : newInstalls) {
Assert.assertEquals(true, install.getJsonValue("fullVersion").toString().startsWith(latestProductionCorePrefix));
}
}
use of com.serotonin.json.type.JsonValue in project ma-core-public by infiniteautomation.
the class StoreLatestProductionTest method testThreeThreeDevelopmentVersion.
// @Test
public void testThreeThreeDevelopmentVersion() throws JsonException, IOException, HttpException {
// Setup json
json.put("upgradeVersionState", UpgradeVersionState.DEVELOPMENT);
json.put("currentVersionState", UpgradeVersionState.DEVELOPMENT);
jsonModules.put("core", "3.3.0-SNAPSHOT");
jsonModules.put("mangoApi", "3.3.0-SNAPSHOT");
String url = baseUrl + "/servlet/versionCheck";
HttpPost post = new HttpPost(url);
StringWriter stringWriter = new StringWriter();
new JsonWriter(JSON_CONTEXT, stringWriter).writeObject(json);
String requestData = stringWriter.toString();
post.setEntity(new StringEntity(requestData));
String responseData = HttpUtils4.getTextContent(getHttpClient(30000), post, 1);
JsonTypeReader jsonReader = new JsonTypeReader(responseData);
JsonValue response = jsonReader.read();
// printResponse(response);
Assert.assertNotNull(response.getJsonValue("versionState"));
Assert.assertEquals("PRODUCTION", response.getJsonValue("versionState").toString());
// Assert newInstalls-oldCore should be empty
Assert.assertNotNull(response.getJsonValue("newInstalls-oldCore"));
JsonArray newInstallsOldCore = response.getJsonValue("newInstalls-oldCore").toJsonArray();
Assert.assertEquals(true, newInstallsOldCore.size() == 0);
// Assert update-versionState
Assert.assertNull(response.getJsonValue("update-versionState"));
// Assert updates for this core iff major upgrade available
Assert.assertNotNull(response.getJsonValue("updates"));
JsonArray updates = response.getJsonValue("updates").toJsonArray();
Assert.assertEquals(true, updates.size() == 0);
// Assert upgrades
Assert.assertNotNull(response.getJsonValue("upgrades"));
JsonArray upgrades = response.getJsonValue("upgrades").toJsonArray();
Assert.assertEquals(true, upgrades.size() > 0);
for (JsonValue upgrade : upgrades) {
Assert.assertEquals(true, upgrade.getJsonValue("fullVersion").toString().startsWith(latestProductionCorePrefix));
}
// Assert newInstalls should be for latest production core
Assert.assertNotNull(response.getJsonValue("newInstalls"));
JsonArray newInstalls = response.getJsonValue("newInstalls").toJsonArray();
Assert.assertEquals(true, newInstalls.size() > 0);
for (JsonValue install : newInstalls) {
Assert.assertEquals(true, install.getJsonValue("fullVersion").toString().startsWith(latestProductionCorePrefix));
}
}
use of com.serotonin.json.type.JsonValue in project ma-core-public by infiniteautomation.
the class StoreLatestProductionTest method testThreeTwoDevelopmentVersion.
// @Test
public void testThreeTwoDevelopmentVersion() throws JsonException, IOException, HttpException {
// Setup json
json.put("upgradeVersionState", UpgradeVersionState.DEVELOPMENT);
json.put("currentVersionState", UpgradeVersionState.DEVELOPMENT);
jsonModules.put("core", latestDevelopmentCore);
jsonModules.put("mangoApi", "3.2.3-SNAPSHOT");
String url = baseUrl + "/servlet/versionCheck";
HttpPost post = new HttpPost(url);
StringWriter stringWriter = new StringWriter();
new JsonWriter(JSON_CONTEXT, stringWriter).writeObject(json);
String requestData = stringWriter.toString();
post.setEntity(new StringEntity(requestData));
String responseData = HttpUtils4.getTextContent(getHttpClient(30000), post, 1);
JsonTypeReader jsonReader = new JsonTypeReader(responseData);
JsonValue response = jsonReader.read();
printResponse(response);
Assert.assertNotNull(response.getJsonValue("versionState"));
Assert.assertEquals("PRODUCTION", response.getJsonValue("versionState").toString());
// Assert newInstalls-oldCore should be empty
Assert.assertNotNull(response.getJsonValue("newInstalls-oldCore"));
JsonArray newInstallsOldCore = response.getJsonValue("newInstalls-oldCore").toJsonArray();
Assert.assertEquals(true, newInstallsOldCore.size() == 0);
// Assert update-versionState
Assert.assertNull(response.getJsonValue("update-versionState"));
// Assert updates for this core iff major upgrade available
Assert.assertNotNull(response.getJsonValue("updates"));
JsonArray updates = response.getJsonValue("updates").toJsonArray();
Assert.assertEquals(true, updates.size() == 0);
// Assert upgrades
Assert.assertNotNull(response.getJsonValue("upgrades"));
JsonArray upgrades = response.getJsonValue("upgrades").toJsonArray();
Assert.assertEquals(true, upgrades.size() > 0);
for (JsonValue upgrade : upgrades) {
Assert.assertEquals(true, upgrade.getJsonValue("fullVersion").toString().startsWith(latestProductionCorePrefix));
}
// Assert newInstalls should be for latest production core
Assert.assertNotNull(response.getJsonValue("newInstalls"));
JsonArray newInstalls = response.getJsonValue("newInstalls").toJsonArray();
Assert.assertEquals(true, newInstalls.size() > 0);
for (JsonValue install : newInstalls) {
Assert.assertEquals(true, install.getJsonValue("fullVersion").toString().startsWith(latestProductionCorePrefix));
}
}
use of com.serotonin.json.type.JsonValue in project ma-core-public by infiniteautomation.
the class StoreLatestProductionTest method testTwoEightEightReleaseVersion.
// @Test
public void testTwoEightEightReleaseVersion() throws JsonException, IOException, HttpException {
// Setup json
json.put("upgradeVersionState", UpgradeVersionState.PRODUCTION);
json.put("currentVersionState", UpgradeVersionState.PRODUCTION);
jsonModules.put("core", "2.8.8");
jsonModules.put("mangoApi", "1.2.0");
String url = baseUrl + "/servlet/versionCheck";
HttpPost post = new HttpPost(url);
StringWriter stringWriter = new StringWriter();
new JsonWriter(JSON_CONTEXT, stringWriter).writeObject(json);
String requestData = stringWriter.toString();
post.setEntity(new StringEntity(requestData));
String responseData = HttpUtils4.getTextContent(getHttpClient(30000), post, 1);
JsonTypeReader jsonReader = new JsonTypeReader(responseData);
JsonValue response = jsonReader.read();
// printResponse(response);
Assert.assertNotNull(response.getJsonValue("versionState"));
Assert.assertEquals("PRODUCTION", response.getJsonValue("versionState").toString());
// Assert newInstalls-oldCore should be for 2.8
Assert.assertNotNull(response.getJsonValue("newInstalls-oldCore"));
JsonArray newInstallsOldCore = response.getJsonValue("newInstalls-oldCore").toJsonArray();
Assert.assertEquals(true, newInstallsOldCore.size() > 0);
for (JsonValue nioc : newInstallsOldCore) {
if (nioc.getJsonValue("name").toString().equals("meta"))
Assert.assertEquals(true, nioc.getJsonValue("fullVersion").toString().equals("2.3.0"));
}
// Assert update-versionState
Assert.assertNotNull(response.getJsonValue("update-versionState"));
Assert.assertEquals("PRODUCTION", response.getJsonValue("update-versionState").toString());
// Assert updates for current core
Assert.assertNotNull(response.getJsonValue("updates"));
JsonArray updates = response.getJsonValue("updates").toJsonArray();
Assert.assertEquals(true, updates.size() > 0);
for (JsonValue upgrade : updates) {
if (upgrade.getJsonValue("name").toString().equals("mangoApi"))
Assert.assertEquals(true, upgrade.getJsonValue("fullVersion").toString().equals("1.2.1"));
}
// Assert upgrades
Assert.assertNotNull(response.getJsonValue("upgrades"));
JsonArray upgrades = response.getJsonValue("upgrades").toJsonArray();
Assert.assertEquals(true, upgrades.size() > 0);
for (JsonValue upgrade : upgrades) {
if (upgrade.getJsonValue("name").toString().equals("core")) {
Assert.assertEquals(true, upgrade.getJsonValue("fullVersion").toString().startsWith(latestProductionCore));
} else {
Assert.assertEquals(true, upgrade.getJsonValue("fullVersion").toString().startsWith(latestProductionCorePrefix));
}
}
// Assert newInstalls should be for latest production core
Assert.assertNotNull(response.getJsonValue("newInstalls"));
JsonArray newInstalls = response.getJsonValue("newInstalls").toJsonArray();
Assert.assertEquals(true, newInstalls.size() > 0);
for (JsonValue install : newInstalls) {
Assert.assertEquals(true, install.getJsonValue("fullVersion").toString().startsWith(latestProductionCorePrefix));
}
}
Aggregations