//Verify new package is available after renaming
URL url1 = new URL(baseURL, "rest/packages/testRenamePackageFromAtomNew");
HttpURLConnection conn1 = (HttpURLConnection)url1.openConnection();
conn1.setRequestProperty("Authorization",
"Basic " + new Base64().encodeToString(( "admin:admin".getBytes() )));
conn1.setRequestMethod("GET");
conn1.setRequestProperty("Accept", MediaType.APPLICATION_ATOM_XML);
conn1.connect();
//System.out.println(GetContent(conn));
assertEquals (200, conn1.getResponseCode());
assertEquals(MediaType.APPLICATION_ATOM_XML, conn1.getContentType());
InputStream in = conn1.getInputStream();
assertNotNull(in);
doc = abdera.getParser().parse(in);
entry = doc.getRoot();
assertEquals(baseURL.getPath() + "rest/packages/testRenamePackageFromAtomNew", entry.getBaseUri().getPath());
assertEquals("testRenamePackageFromAtomNew", entry.getTitle());
assertTrue(entry.getPublished() != null);
assertEquals("renamed package testRenamePackageFromAtom", entry.getSummary());
//Verify the old package does not exist after renaming
URL url2 = new URL(baseURL, "rest/packages/testRenamePackageFromAtom");
HttpURLConnection conn2 = (HttpURLConnection)url2.openConnection();
conn2.setRequestProperty("Authorization",
"Basic " + new Base64().encodeToString(( "admin:admin".getBytes() )));
conn2.setRequestMethod("GET");
conn2.setRequestProperty("Accept", MediaType.APPLICATION_ATOM_XML);
conn2.connect();
//System.out.println(IOUtils.toString(connection.getInputStream()));
assertEquals (404, conn2.getResponseCode());
//Roll back changes.
resp = client.delete(new URL(baseURL, "rest/packages/testRenamePackageFromAtomNew").toExternalForm());
assertEquals(ResponseType.SUCCESS, resp.getType());
//Verify the package is indeed deleted
URL url3 = new URL(baseURL, "rest/packages/testRenamePackageFromAtomNew");
HttpURLConnection conn3 = (HttpURLConnection)url3.openConnection();
conn3.setRequestProperty("Authorization",
"Basic " + new Base64().encodeToString(( "admin:admin".getBytes() )));
conn3.setRequestMethod("GET");
conn3.setRequestProperty("Accept", MediaType.APPLICATION_ATOM_XML);
conn3.connect();
//System.out.println(IOUtils.toString(connection.getInputStream()));
assertEquals (404, conn3.getResponseCode());