@Test public void return_null_if_resource_not_found() { assertThat(i18nClassloader.getResource("org/unknown.properties")).isNull(); }
@Test public void define_delete_action() { WebService.Action action = ws.getDef(); assertThat(action).isNotNull(); assertThat(action.isPost()).isTrue(); assertThat(action.handler()).isNotNull(); assertThat(action.responseExample()).isNull(); assertThat(action.params()).hasSize(1); }
/** * Verifies that the {@link NullClassLoader} works and never finds the named class. This is a * control which ensures that tests depending on <tt>NullClassLoader</tt> are valid. */ @Test public void testNullClassLoader() throws Exception { System.out.println("\nStarting ClassPathLoaderTest#testNullClassLoader"); ClassLoader cl = new NullClassLoader(); String classToLoad = "java.lang.String"; assertThatThrownBy(() -> { Class.forName(classToLoad, true, cl); }).isInstanceOf(ClassNotFoundException.class); String resourceToGet = "java/lang/String.class"; URL url = cl.getResource(resourceToGet); assertThat(url).isNull(); InputStream is = cl.getResourceAsStream(resourceToGet); assertThat(is).isNull(); }
/** * Verifies that <tt>getResource</tt> will skip TCCL if <tt>excludeThreadContextClassLoader</tt> * has been set to true. */ @Test public void testGetResourceExcludeTCCL() throws Exception { System.out.println("\nStarting ClassPathLoaderTest#testGetResourceExcludeTCCL"); ClassPathLoader dcl = ClassPathLoader.createWithDefaults(true); String resourceToGet = "com/nowhere/testGetResourceExcludeTCCL.rsc"; assertThat(dcl.getResource(resourceToGet)).isNull(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { // ensure that TCCL is only CL that can find this resource Thread.currentThread().setContextClassLoader(new GeneratingClassLoader()); assertThat(dcl.getResource(resourceToGet)).isNull(); } finally { Thread.currentThread().setContextClassLoader(cl); } }
@Test public void definition() { WebService.Action action = wsTester.getDef(); assertThat(action.key()).isEqualTo("delete"); assertThat(action.isPost()).isTrue(); assertThat(action.description()).isEqualTo("Delete an organization.<br/>" + "Require 'Administer System' permission on the specified organization. Organization support must be enabled."); assertThat(action.isInternal()).isTrue(); assertThat(action.since()).isEqualTo("6.2"); assertThat(action.handler()).isNotNull(); assertThat(action.params()).hasSize(1); assertThat(action.responseExample()).isNull(); assertThat(action.param("organization")) .matches(param -> param.isRequired()) .matches(param -> "foo-company".equals(param.exampleValue())) .matches(param -> "Organization key".equals(param.description())); }
@Test public void verify_definition() { WebService.Action action = ws.getDef(); assertThat(action.key()).isEqualTo("set_homepage"); assertThat(action.isInternal()).isTrue(); assertThat(action.isPost()).isTrue(); assertThat(action.since()).isEqualTo("7.0"); assertThat(action.description()).isEqualTo("Set homepage of current user.<br> Requires authentication."); assertThat(action.responseExample()).isNull(); assertThat(action.params()).hasSize(4); WebService.Param typeParam = action.param("type"); assertThat(typeParam.isRequired()).isTrue(); assertThat(typeParam.description()).isEqualTo("Type of the requested page"); WebService.Param componentParam = action.param("component"); assertThat(componentParam.isRequired()).isFalse(); assertThat(componentParam.description()).isEqualTo("Project key. It should only be used when parameter 'type' is set to 'PROJECT'"); assertThat(componentParam.since()).isEqualTo("7.1"); WebService.Param branchParam = action.param("branch"); assertThat(branchParam.isRequired()).isFalse(); assertThat(branchParam.description()).isEqualTo("Branch key. It can only be used when parameter 'type' is set to 'PROJECT'"); assertThat(branchParam.since()).isEqualTo("7.1"); WebService.Param organizationParam = action.param("organization"); assertThat(organizationParam.isRequired()).isFalse(); assertThat(organizationParam.description()).isEqualTo("Organization key. It should only be used when parameter 'type' is set to 'ORGANIZATION'"); assertThat(organizationParam.since()).isEqualTo("7.1"); }
@Test public void verify_definition() { WebService.Action action = wsTester.getDef(); assertThat(action.key()).isEqualTo("unset_root"); assertThat(action.isInternal()).isTrue(); assertThat(action.isPost()).isTrue(); assertThat(action.since()).isEqualTo("6.2"); assertThat(action.description()).isEqualTo("Make the specified user not root.<br/>" + "Requires to be root."); assertThat(action.responseExample()).isNull(); assertThat(action.deprecatedKey()).isNull(); assertThat(action.deprecatedSince()).isNull(); assertThat(action.handler()).isSameAs(underTest); assertThat(action.params()).hasSize(1); WebService.Param param = action.param("login"); assertThat(param.isRequired()).isTrue(); assertThat(param.description()).isEqualTo("A user login"); assertThat(param.defaultValue()).isNull(); assertThat(param.deprecatedSince()).isNull(); assertThat(param.deprecatedKey()).isNull(); assertThat(param.exampleValue()).isEqualTo("admin"); }
@Test public void verify_definition() { WebService.Action action = wsTester.getDef(); assertThat(action.key()).isEqualTo("set_root"); assertThat(action.isInternal()).isTrue(); assertThat(action.isPost()).isTrue(); assertThat(action.since()).isEqualTo("6.2"); assertThat(action.description()).isEqualTo("Make the specified user root.<br/>" + "Requires to be root."); assertThat(action.responseExample()).isNull(); assertThat(action.deprecatedKey()).isNull(); assertThat(action.deprecatedSince()).isNull(); assertThat(action.handler()).isSameAs(underTest); assertThat(action.params()).hasSize(1); WebService.Param param = action.param("login"); assertThat(param.isRequired()).isTrue(); assertThat(param.description()).isEqualTo("A user login"); assertThat(param.defaultValue()).isNull(); assertThat(param.deprecatedSince()).isNull(); assertThat(param.deprecatedKey()).isNull(); assertThat(param.exampleValue()).isEqualTo("admin"); }
@Test public void action_update_is_defined() { logInAsSystemAdministrator(); WsTester wsTester = new WsTester(); WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY); underTest.define(newController); newController.done(); WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY); assertThat(controller.actions()).extracting("key").containsExactly(ACTION_KEY); WebService.Action action = controller.actions().iterator().next(); assertThat(action.isPost()).isTrue(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNull(); assertThat(action.params()).hasSize(1); WebService.Param key = action.param(KEY_PARAM); assertThat(key).isNotNull(); assertThat(key.isRequired()).isTrue(); assertThat(key.description()).isNotNull(); }
@Test public void action_cancel_all_is_defined() { WsTester wsTester = new WsTester(); WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY); underTest.define(newController); newController.done(); WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY); assertThat(controller.actions()).extracting("key").containsExactly("cancel_all"); WebService.Action action = controller.actions().iterator().next(); assertThat(action.isPost()).isTrue(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNull(); assertThat(action.params()).isEmpty(); }
@Test public void action_install_is_defined() { logInAsSystemAdministrator(); WsTester wsTester = new WsTester(); WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY); underTest.define(newController); newController.done(); WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY); assertThat(controller.actions()).extracting("key").containsExactly(ACTION_KEY); WebService.Action action = controller.actions().iterator().next(); assertThat(action.isPost()).isTrue(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNull(); assertThat(action.params()).hasSize(1); WebService.Param keyParam = action.param(KEY_PARAM); assertThat(keyParam).isNotNull(); assertThat(keyParam.isRequired()).isTrue(); assertThat(keyParam.description()).isNotNull(); }
@Test public void action_uninstall_is_defined() { logInAsSystemAdministrator(); WsTester wsTester = new WsTester(); WebService.NewController newController = wsTester.context().createController(DUMMY_CONTROLLER_KEY); underTest.define(newController); newController.done(); WebService.Controller controller = wsTester.controller(DUMMY_CONTROLLER_KEY); assertThat(controller.actions()).extracting("key").containsExactly(ACTION_KEY); WebService.Action action = controller.actions().iterator().next(); assertThat(action.isPost()).isTrue(); assertThat(action.description()).isNotEmpty(); assertThat(action.responseExample()).isNull(); assertThat(action.params()).hasSize(1); WebService.Param keyParam = action.param(KEY_PARAM); assertThat(keyParam).isNotNull(); assertThat(keyParam.isRequired()).isTrue(); assertThat(keyParam.description()).isNotNull(); }
@Test public void shouldCheckEnterpriseLicense() { assumeThat(Neo4jContainerTest.class.getResource(ACCEPTANCE_FILE_LOCATION)).isNull(); String expectedImageName = "neo4j:3.5.0-enterprise"; assertThatExceptionOfType(IllegalStateException.class) .isThrownBy(() -> new Neo4jContainer().withEnterpriseEdition()) .withMessageContaining("The image " + expectedImageName + " requires you to accept a license agreement."); }
assertThat(action.handler()).isEqualTo(underTest); assertThat(action.params()).hasSize(5); assertThat(action.responseExample()).isNull();
@Test public void shouldReturnNullWhenNoChildCanSupplyResource() throws IOException { assertThat(this.testee.getResource("unknown")).isNull(); }
/** * @throws MalformedURLException * @see Issue #128 */ @Test public void shouldBeAbleToSetNodePropertiesToNull() throws MalformedURLException { Movie movie = new Movie("Zootopia", 2016); movie.setImdbUrl(new URL("http://www.imdb.com/title/tt2948356/")); session.save(movie); movie.setTitle(null); movie.setImdbUrl(null); session.save(movie); movie = session.load(Movie.class, movie.getUuid()); assertThat(movie.getTitle()).isNull(); assertThat(movie.getImdbUrl()).isNull(); session.clear(); movie = session.load(Movie.class, movie.getUuid()); assertThat(movie.getTitle()).isNull(); assertThat(movie.getImdbUrl()).isNull(); } }