use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class FileAdaptorTest method isDirectoryTest.
private AdaptorTestResultEntry isDirectoryTest(GATContext gatContext, Preferences preferences, String host, String filename, int tabs, boolean correctValue) {
FileInterface file = null;
try {
file = GAT.createFile(gatContext, preferences, "any://" + host + "/" + filename).getFileInterface();
} catch (GATObjectCreationException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
boolean isDir = false;
long start = System.currentTimeMillis();
try {
isDir = file.isDirectory();
} catch (GATInvocationException e) {
return new AdaptorTestResultEntry(false, 0, e);
}
long stop = System.currentTimeMillis();
return new AdaptorTestResultEntry(isDir == correctValue, (stop - start), null);
}
use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class FileOutputStreamAdaptorTest method test.
public AdaptorTestResult test(String adaptor, String host) {
AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
GATContext gatContext = new GATContext();
PasswordSecurityContext password = new PasswordSecurityContext("username", "TeMpPaSsWoRd");
password.addNote("adaptors", "ftp");
gatContext.addSecurityContext(password);
// CertificateSecurityContext ctxt = new CertificateSecurityContext(null, null, "username", "passphrase");
// gatContext.addSecurityContext(ctxt);
Preferences preferences = new Preferences();
preferences.put("fileoutputstream.adaptor.name", adaptor);
FileOutputStream out = null;
try {
out = GAT.createFileOutputStream(gatContext, preferences, "any://" + host + "/JavaGAT-test-fileoutputstream");
} catch (GATObjectCreationException e) {
adaptorTestResult.put("create ", new AdaptorTestResultEntry(false, 0, e));
run(host, "fileoutputstream-adaptor-test-clean.sh");
return adaptorTestResult;
}
byte[] large = new byte[10 * 1024 * 1024];
for (int i = 0; i < large.length; i++) {
large[i] = 'a';
}
adaptorTestResult.put("write (small)", writeTest(out, "test\n"));
adaptorTestResult.put("write (large)", writeTest(out, new String(large)));
adaptorTestResult.put("flush ", flushTest(out));
adaptorTestResult.put("close ", closeTest(out));
run(host, "fileoutputstream-adaptor-test-clean.sh");
return adaptorTestResult;
}
use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class AdvertServiceAdaptorTest method test.
public AdaptorTestResult test(String adaptor, String host) {
AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
Preferences preferences = new Preferences();
preferences.put("advertservice.adaptor.name", adaptor);
AdvertService advertService = null;
try {
advertService = GAT.createAdvertService(preferences);
} catch (GATObjectCreationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MetaData meta = new MetaData();
meta.put("version", "5.0");
meta.put("price", "2000");
adaptorTestResult.put("put object '1' at path 'a'", addTest(advertService, "1", meta, "a"));
adaptorTestResult.put("getMetaData 'a' ", getMetaDataTest(advertService, "a", meta));
meta = new MetaData();
meta.put("version", "5.0");
meta.put("price", "50");
adaptorTestResult.put("put object '2' at path 'b'", addTest(advertService, "2", meta, "b"));
adaptorTestResult.put("test path 'a' (CORRECT) ", getAdvertisableTest(advertService, "a", "1", true));
adaptorTestResult.put("test path 'a' (INCORRECT) ", getAdvertisableTest(advertService, "a", "2", false));
adaptorTestResult.put("test path 'b' (CORRECT) ", getAdvertisableTest(advertService, "b", "2", true));
adaptorTestResult.put("export ", exportTest(advertService, "any://" + host + "/exported-advert-database"));
meta = new MetaData();
meta.put("version", "9.1");
meta.put("price", "50");
adaptorTestResult.put("put object '3' at path 'c'", addTest(advertService, "3", meta, "c"));
adaptorTestResult.put("test path 'c' (CORRECT) ", getAdvertisableTest(advertService, "c", "3", true));
adaptorTestResult.put("import ", importTest(advertService, "any://" + host + "/exported-advert-database"));
adaptorTestResult.put("test path 'c' (INCORRECT) ", getAdvertisableTest(advertService, "c", null, true));
meta = new MetaData();
meta.put("price", "50");
adaptorTestResult.put("find price=50 ", findTest(advertService, meta, new String[] { "/b" }, true));
meta = new MetaData();
meta.put("version", "5.0");
adaptorTestResult.put("find version=5.0 ", findTest(advertService, meta, new String[] { "/b", "/a" }, true));
adaptorTestResult.put("delete 'b' ", deleteTest(advertService, "b"));
adaptorTestResult.put("setPWD 'test' ", setPWDTest(advertService, "/test"));
adaptorTestResult.put("getPWD 'test' ", getPWDTest(advertService, "/test"));
return adaptorTestResult;
}
use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class AllResourceBrokerAdaptorsTest method printResults.
private static void printResults(AdaptorTestResult[] results, String host) throws IOException {
File outFile = new File("ResourceBroker-results-" + host + ".html");
if (!outFile.exists()) {
outFile.createNewFile();
}
FileOutputStream out = new FileOutputStream(outFile);
out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n".getBytes());
out.write("<html>\n".getBytes());
out.write("<head>\n".getBytes());
out.write("<title>JavaGAT test results: ResourceBroker</title>\n".getBytes());
out.write(("<script>\n" + "function showhide(id){\n" + "\tif (document.getElementById){\n" + "\t\tobj = document.getElementById(id);\n" + "\t\tif (obj.style.display == \"none\"){\n" + "\t\t\tobj.style.display = \"\";\n" + "\t\t} else {\n" + "\t\t\tobj.style.display = \"none\";\n" + "\t\t}\n" + "\t}\n" + "}\n" + "</script>\n").getBytes());
out.write("</head>\n".getBytes());
out.write("<body>\n".getBytes());
out.write("<table frame=box cellpadding=5 cellspacing=0>\n".getBytes());
out.write("<tr>\n".getBytes());
out.write("<td></td>\n".getBytes());
for (AdaptorTestResult result : results) {
out.write(("<td align=right>" + result.getAdaptor() + "</td>\n").getBytes());
}
out.write("</tr>\n".getBytes());
boolean background = true;
String[] keys = results[0].getTestResultEntries().keySet().toArray(new String[results[0].getTestResultEntries().size()]);
Arrays.sort(keys);
for (String key : keys) {
if (background) {
out.write("<tr bgcolor=#DDDDDD>\n".getBytes());
} else {
out.write("<tr bgcolor=#FFFFFF>\n".getBytes());
}
background = !background;
out.write(("<td>" + key + "</td>\n").getBytes());
for (AdaptorTestResult result : results) {
AdaptorTestResultEntry entry = result.getTestResultEntries().get(key);
if (entry == null) {
out.write("<td align=right>not present</td>\n".getBytes());
continue;
}
if (entry.getException() == null && !entry.getResult()) {
out.write("<td align=right bgcolor=#FFDDDD>".getBytes());
} else {
out.write("<td align=right>".getBytes());
}
if (entry.getException() == null) {
out.write((entry.getTime() + " ms").getBytes());
} else {
if (entry.getException() instanceof GATInvocationException && ((GATInvocationException) entry.getException()).getExceptions().length > 0 && ((GATInvocationException) entry.getException()).getExceptions()[0] instanceof UnsupportedOperationException) {
out.write("n.i.".getBytes());
} else if (entry.getException() instanceof GATObjectCreationException && ((GATObjectCreationException) entry.getException()).getExceptions().length > 0 && ((GATObjectCreationException) entry.getException()).getExceptions()[0] instanceof GATObjectCreationException && ((GATObjectCreationException) ((GATObjectCreationException) entry.getException()).getExceptions()[0]).getExceptions().length > 0 && ((GATObjectCreationException) ((GATObjectCreationException) entry.getException()).getExceptions()[0]).getExceptions()[0] instanceof AdaptorNotApplicableException) {
out.write("n.a.".getBytes());
} else {
out.write(("<div style=\"display: none;\" id=\"" + result.getAdaptor() + key + "\">\n").getBytes());
out.write((entry.getException().toString().replace("\n", "<br/>\n") + "\n").getBytes());
StringWriter s = new StringWriter();
PrintWriter p = new PrintWriter(s);
entry.getException().printStackTrace(p);
out.write((s.toString().replace("\n", "<br/>\n") + "\n").getBytes());
out.write("</div>\n".getBytes());
out.write(("<a href=\"#\" onclick=\"showhide('" + result.getAdaptor() + key + "'); return(false);\">show/hide</a>\n").getBytes());
}
}
out.write("</td>\n".getBytes());
}
out.write("</tr>\n".getBytes());
}
out.write("<tr>\n".getBytes());
out.write("<td>total</td>\n".getBytes());
for (AdaptorTestResult result : results) {
out.write(("<td align=right>" + result.getTotalRunTime() + " ms</td>\n").getBytes());
}
out.write("</tr>\n".getBytes());
out.write("<tr>\n".getBytes());
out.write("<td>average</td>\n".getBytes());
for (AdaptorTestResult result : results) {
out.write(("<td align=right>" + result.getAverageRunTime() + " ms</td>\n").getBytes());
}
out.write("</tr>\n".getBytes());
out.write("</table>\n".getBytes());
out.write("</body>\n".getBytes());
out.write("</html>\n".getBytes());
}
use of org.gridlab.gat.GATObjectCreationException in project compss by bsc-wdc.
the class FileInputStreamAdaptorTest method test.
public AdaptorTestResult test(String adaptor, String host) {
run(host, "fileinputstream-adaptor-test-init.sh");
AdaptorTestResult adaptorTestResult = new AdaptorTestResult(adaptor, host);
GATContext gatContext = new GATContext();
PasswordSecurityContext password = new PasswordSecurityContext("username", "TeMpPaSsWoRd");
password.addNote("adaptors", "ftp");
gatContext.addSecurityContext(password);
// CertificateSecurityContext ctxt = new CertificateSecurityContext(null, null, "username", "passphrase");
// gatContext.addSecurityContext(ctxt);
Preferences preferences = new Preferences();
preferences.put("fileinputstream.adaptor.name", adaptor);
FileInputStream in = null;
try {
in = GAT.createFileInputStream(gatContext, preferences, "any://" + host + "/JavaGAT-test-fileinputstream");
} catch (GATObjectCreationException e) {
adaptorTestResult.put("create ", new AdaptorTestResultEntry(false, 0, e));
run(host, "fileinputstream-adaptor-test-clean.sh");
return adaptorTestResult;
}
adaptorTestResult.put("markSupported ", markSupportedTest(in));
adaptorTestResult.put("available: ", availableTest(in, 0, true));
adaptorTestResult.put("read: single char a", readTest(in, 'a', true));
adaptorTestResult.put("read: single char b", readTest(in, 'b', true));
adaptorTestResult.put("read: single char c", readTest(in, 'c', true));
adaptorTestResult.put("read: single char !d", readTest(in, 'q', false));
adaptorTestResult.put("read: small ", readTest(in, "efg".getBytes(), true));
byte[] bytes = new byte[1024 * 1024 * 10];
byte current = 'h';
for (int i = 0; i < bytes.length; i++) {
bytes[i] = current;
if (current == 'z') {
current = '\n';
} else if (current == '\n') {
current = 'a';
} else {
current++;
}
}
adaptorTestResult.put("read: large ", readTest(in, bytes, true));
adaptorTestResult.put("skip: small ", skipTest(in, 100));
adaptorTestResult.put("skip: large ", skipTest(in, 10 * 1024 * 1024));
adaptorTestResult.put("close ", closeTest(in));
run(host, "fileinputstream-adaptor-test-clean.sh");
return adaptorTestResult;
}
Aggregations