@Test public void testParse() throws Exception { OperationsJsonParser parser = new OperationsJsonParser(); Operations actual = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/operations/valid.json")); assertThat( actual, is( new Operations( Collections.singleton( new OperationGroup( "opsbar-transitions", Collections.singleton( new OperationLink( "action_id_4", "issueaction-workflow-transition", "Start Progress", "Start work on the issue", "/secure/WorkflowUIDispatcher.jspa?id=93813&action=4&atl_token=", 10, null)), Collections.singleton( new OperationGroup( null, Collections.<OperationLink>emptyList(), Collections.<OperationGroup>emptyList(), new OperationHeader( "opsbar-transitions_more", "Workflow", null, null), null)), null, 20))))); }
@Test public void testParse() throws Exception { final SessionCookieJsonParser parser = new SessionCookieJsonParser(); assertEquals( new SessionCookie("JSESSIONID", "E5BD072ABEE0082DE4D6C8C2B6D96B79"), parser.parse(ResourceUtil.getJsonObjectFromResource("/json/sessionCookie/valid.json"))); }
@Test public void test_dir_returns_null() { String tmpDir = System.getProperty("java.io.tmpdir"); assertNotNull("Didn't find a temp dir", tmpDir); assertFalse("Didn't find a temp dir", tmpDir.isEmpty()); System.out.println("Temp dir: " + tmpDir); InputStream inputStream = ResourceUtil.getInputStream(tmpDir); assertNull("Should be null", inputStream); }
@Test public void test_file_found_in_relative_path_returns_null() { File file = new File("config/ehcache.xml"); assertTrue( "File in relative path should exist, just for test, any file will do", file.exists() && !file.isAbsolute() && !file.isDirectory()); InputStream inputStream = ResourceUtil.getInputStream("config/ehcache.xml"); assertNull("Should be null", inputStream); }
@Test public void test_resource_file_in_folder_returns_input_stream() throws IOException { String reference = "bootstrap/ehcache.xml"; File file = new File(reference); assertTrue("File should not exist in relative path.", !file.exists()); InputStream inputStream = ResourceUtil.getInputStream(reference); assertNotNull( "This should be a file in resources only. Just for test, any file will do", inputStream); }
@Test public void test_web_addr_returns_null() { InputStream inputStream = ResourceUtil.getInputStream("http://google.com"); assertNull("Should be null", inputStream); }
@Test public void test_null_string_returns_null() { InputStream inputStream = ResourceUtil.getInputStream(null); assertNull("Should be null", inputStream); }
@Test public void test_resource_dir_returns_null() { InputStream inputStream = ResourceUtil.getInputStream("org"); assertNull("Should be null", inputStream); }
@Test public void test_File_Does_Not_Exist_returns_null() { InputStream inputStream = ResourceUtil.getInputStream("mumble jumble"); assertNull("Should be null", inputStream); }
/** * Test method for {@link * org.talend.commons.utils.resource.ResourceUtil#getFileFromResource(java.lang.Class, * java.lang.String)}. * * @throws URISyntaxException * @throws IOException */ @Test public void testGetFileFromResource() throws IOException, URISyntaxException { String filename = "/data/TextFile.txt"; // $NON-NLS-1$ File file = ResourceUtil.getFileFromResource(this.getClass(), filename); Assert.assertNotNull(file); }