public void testMatrix() { final Reference ref1 = new Reference("http://domain.tld/whatever/a=1;b=2;c=4?x=a&y=b"); final Reference ref2 = new Reference("http://domain.tld/whatever/a=1/foo;b=2;c=4;d?x=a&y=b"); final Reference ref3 = new Reference("http://domain.tld/whatever/a=1;b=2;c=4/foo?x=a&y=b"); assertTrue(ref1.hasMatrix()); assertTrue(ref2.hasMatrix()); assertFalse(ref3.hasMatrix()); assertEquals("b=2;c=4", ref1.getMatrix()); assertEquals("b=2;c=4;d", ref2.getMatrix()); final Form form1 = ref1.getMatrixAsForm(); assertEquals("2", form1.getFirstValue("b")); assertEquals("4", form1.getFirstValue("c")); final Form form2 = ref1.getMatrixAsForm(); assertEquals("2", form2.getFirstValue("b")); assertEquals("4", form2.getFirstValue("c")); assertNull(form2.getFirstValue("d")); final Form newForm = new Form(); newForm.add("a", "1"); newForm.add("b", "2"); newForm.add("c", "4"); assertEquals("a=1;b=2;c=4", newForm.getMatrixString()); }
// TODO Die Parameter beim Request werden nicht korrekt übergeben. Keine // Ahnung woran es liegt. @Test(enabled = false) public void testPostCompute() { // connect to api clientResource.setReference( OcciConfig.getInstance().config.getString("occi.server.location") + "compute"); // Tests if client resource is connected to api Assert.assertNotNull(clientResource); // try to create a compute resource String architecture = "x86"; String cores = "20"; String hostname = "Ubuntu"; String speed = "2000000"; String memory = "1024"; String category = "compute"; // create new request and add all attributes Form form = new Form(); form.add("occi.compute.architecture", architecture); form.add("occi.compute.cores", cores); form.add("occi.compute.hostname", hostname); form.add("occi.compute.speed", speed); form.add("occi.compute.memory", memory); form.add("category", category); System.out.println("\n FORM " + form.toString()); // create new representation Representation representation = null; try { // send post request representation = clientResource.post(form.toString(), MediaType.TEXT_PLAIN); } catch (Exception ex) { System.out.println("Failed to execute POST request " + ex.getMessage()); } Assert.assertNotNull(representation); // get request and print it in debugger Request request = Request.getCurrent(); System.out.println(request.toString() + "\n\n" + form.getMatrixString()); System.out.println("--------------------------------"); // get current response Response response = Response.getCurrent(); Assert.assertNotNull(response); System.out.println("Response: " + response.toString()); try { representation.write(System.out); } catch (IOException e) { System.out.println(e.getMessage()); } System.out.println("\n--------------------------------"); }