use of org.osgi.framework.Bundle in project tesb-studio-se by Talend.
the class FelixLogsModelTest method testToString.
/**
* Test method for {@link org.talend.designer.esb.runcontainer.logs.FelixLogsModel#toString()}.
*
* @throws Exception
*/
@Test
public void testToString() throws Exception {
Bundle b = Platform.getBundle("org.talend.designer.esb.runcontainer.test");
//$NON-NLS-1$
URL url = FileLocator.toFileURL(FileLocator.find(b, new Path("resources"), null));
//$NON-NLS-1$
File responseFile = new File(url.getPath() + "/FelixLogsModelTest.json");
Assert.assertTrue(responseFile.exists());
String json = new String(Files.readAllBytes(responseFile.toPath()));
String data = "\"data\":";
int dataPos = json.indexOf(data) + 7;
String line = json.substring(dataPos, json.length());
ObjectMapper mapper = new ObjectMapper();
FelixLogsModel[] logs = mapper.readValue(line, FelixLogsModel[].class);
Assert.assertEquals(logs.length, 100);
}
use of org.osgi.framework.Bundle in project tesb-studio-se by Talend.
the class FileUtilTest method testIsContainerArchive.
/**
* Test method for {@link org.talend.designer.esb.runcontainer.util.FileUtil#isContainerArchive(java.lang.String)}.
*
* @throws Exception
*/
@Test
public void testIsContainerArchive() throws Exception {
Bundle b = Platform.getBundle("org.talend.designer.esb.runcontainer.test");
//$NON-NLS-1$
URL url = FileLocator.toFileURL(FileLocator.find(b, new Path("resources"), null));
Assert.assertTrue(FileUtil.isContainerArchive(url.getPath() + "/Talend-ESB-V6.4.0-structure.zip"));
Assert.assertTrue(FileUtil.isContainerArchive(url.getPath() + "/Talend-Runtime-V6.4.0-structure.zip"));
Assert.assertFalse(FileUtil.isContainerArchive(url.getPath() + "/Talend-ESB-V6.4.0-missing-trun.zip"));
Assert.assertFalse(FileUtil.isContainerArchive(url.getPath() + "/Talend-Runtime-V6.4.0-structure-missing-etc.zip"));
}
use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.
the class JobJavaScriptsWSManager method copyServerConfigFileToTempDir.
private void copyServerConfigFileToTempDir() {
final Bundle b = Platform.getBundle(RepositoryPlugin.PLUGIN_ID);
String sourceFileName;
try {
sourceFileName = //$NON-NLS-1$
FileLocator.toFileURL(FileLocator.find(b, new Path("resources/server-config.wsdd"), null)).getFile();
//$NON-NLS-1$
String targetFileName = getTmpFolder() + PATH_SEPARATOR + "server-config.wsdd";
FilesUtils.copyFile(new File(sourceFileName), new File(targetFileName));
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.
the class TestComponentsAction method getPath.
private String getPath() {
//$NON-NLS-1$
IPath filePath = new Path("components");
Bundle b = Platform.getBundle(TestComponentsPlugin.PLUGINCOMPONENTID);
String dir = null;
try {
URL url = FileLocator.toFileURL(FileLocator.find(b, filePath, null));
dir = url.getPath();
dir = dir.substring(1, dir.length() - 1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return dir;
}
use of org.osgi.framework.Bundle in project tdi-studio-se by Talend.
the class URLUtil method getFragmentResourceURL.
/**
* Return a URL to a file located in your plugin fragment.
*
* @param yourPluginId e.g net.sourceforge.sqlexplorer.oracle
* @param filePath path to file within your fragment e.g. icons/test.gif
* @return URL to the file.
*/
public static URL getFragmentResourceURL(String yourPluginId, String filePath) {
URL url = null;
try {
Bundle bundle = Platform.getBundle(yourPluginId);
//$NON-NLS-1$
URL baseUrl = bundle.getEntry("/");
url = new URL(baseUrl, filePath);
} catch (Exception e) {
SqlBuilderPlugin.log(e.getMessage(), e);
}
return url;
}
Aggregations