List of usage examples for java.lang String getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.commonjava.indy.ftest.core.urls.StoreOneAndSourceStoreUrlInHtmlListingTest.java
@Test public void storeOneFileAndVerifyItInParentDirectoryListing() throws Exception { final byte[] data = "this is a test".getBytes(); final ByteArrayInputStream stream = new ByteArrayInputStream(data); final String root = "/path/to/"; final String path = root + "foo.txt"; client.content().store(hosted, STORE, path, stream); final IndyClientHttp http = getHttp(); final HttpGet request = http.newRawGet(client.content().contentUrl(hosted, STORE, root)); request.addHeader("Accept", "text/html"); final CloseableHttpClient hc = http.newClient(); final CloseableHttpResponse response = hc.execute(request); final InputStream listing = response.getEntity().getContent(); final String html = IOUtils.toString(listing); // TODO: Charset!! final Document doc = Jsoup.parse(html); for (final Element item : doc.select("a.source-link")) { final String fname = item.text(); System.out.printf("Listing contains: '%s'\n", fname); final String href = item.attr("href"); final String expected = client.content().contentUrl(hosted, STORE); assertThat(fname + " does not have a href", href, notNullValue()); assertThat(fname + " has incorrect link: '" + href + "' (" + href.getClass().getName() + ")\nshould be: '" + expected + "' (String)", href, equalTo(expected)); }/*from ww w. ja v a 2s. c om*/ }
From source file:org.commonjava.aprox.ftest.core.urls.StoreOneAndSourceStoreUrlInHtmlListingTest.java
@Test public void storeOneFileAndVerifyItInParentDirectoryListing() throws Exception { final byte[] data = "this is a test".getBytes(); final ByteArrayInputStream stream = new ByteArrayInputStream(data); final String root = "/path/to/"; final String path = root + "foo.txt"; client.content().store(hosted, STORE, path, stream); final AproxClientHttp http = getHttp(); final HttpGet request = http.newRawGet(client.content().contentUrl(hosted, STORE, root)); request.addHeader("Accept", "text/html"); final CloseableHttpClient hc = http.newClient(); final CloseableHttpResponse response = hc.execute(request); final InputStream listing = response.getEntity().getContent(); final String html = IOUtils.toString(listing); // TODO: Charset!! final Document doc = Jsoup.parse(html); for (final Element item : doc.select("a.source-link")) { final String fname = item.text(); System.out.printf("Listing contains: '%s'\n", fname); final String href = item.attr("href"); final String expected = client.content().contentUrl(hosted, STORE); assertThat(fname + " does not have a href", href, notNullValue()); assertThat(fname + " has incorrect link: '" + href + "' (" + href.getClass().getName() + ")\nshould be: '" + expected + "' (String)", href, equalTo(expected)); }/*from w w w .j a v a 2 s .c o m*/ }
From source file:org.commonjava.aprox.folo.ftest.urls.StoreOneAndSourceStoreUrlInHtmlListingTest.java
@Test public void storeOneFileAndVerifyItInParentDirectoryListing() throws Exception { final byte[] data = "this is a test".getBytes(); final ByteArrayInputStream stream = new ByteArrayInputStream(data); final String root = "/path/to/"; final String path = root + "foo.txt"; final String track = "track"; content.store(track, hosted, STORE, path, stream); final AproxClientHttp http = getHttp(); final HttpGet request = http.newRawGet(content.contentUrl(track, hosted, STORE, root)); request.addHeader("Accept", "text/html"); final CloseableHttpClient hc = http.newClient(); final CloseableHttpResponse response = hc.execute(request); final InputStream listing = response.getEntity().getContent(); final String html = IOUtils.toString(listing); // TODO: Charset!! final Document doc = Jsoup.parse(html); for (final Element item : doc.select("a.source-link")) { final String fname = item.text(); System.out.printf("Listing contains: '%s'\n", fname); final String href = item.attr("href"); final String expected = client.content().contentUrl(hosted, STORE); assertThat(fname + " does not have a href", href, notNullValue()); assertThat(fname + " has incorrect link: '" + href + "' (" + href.getClass().getName() + ")\nshould be: '" + expected + "' (String)", href, equalTo(expected)); }// www. jav a 2s . c o m }
From source file:org.commonjava.indy.folo.ftest.urls.StoreOneAndSourceStoreUrlInHtmlListingTest.java
@Test public void storeOneFileAndVerifyItInParentDirectoryListing() throws Exception { final byte[] data = "this is a test".getBytes(); final ByteArrayInputStream stream = new ByteArrayInputStream(data); final String root = "/path/to/"; final String path = root + "foo.txt"; final String track = "track"; content.store(track, hosted, STORE, path, stream); final IndyClientHttp http = getHttp(); final HttpGet request = http.newRawGet(content.contentUrl(track, hosted, STORE, root)); request.addHeader("Accept", "text/html"); final CloseableHttpClient hc = http.newClient(); final CloseableHttpResponse response = hc.execute(request); final InputStream listing = response.getEntity().getContent(); final String html = IOUtils.toString(listing); // TODO: Charset!! final Document doc = Jsoup.parse(html); for (final Element item : doc.select("a.source-link")) { final String fname = item.text(); System.out.printf("Listing contains: '%s'\n", fname); final String href = item.attr("href"); final String expected = client.content().contentUrl(hosted, STORE); assertThat(fname + " does not have a href", href, notNullValue()); assertThat(fname + " has incorrect link: '" + href + "' (" + href.getClass().getName() + ")\nshould be: '" + expected + "' (String)", href, equalTo(expected)); }//w ww. ja v a 2 s.c o m }
From source file:org.commonjava.indy.ftest.core.urls.StoreOneAndVerifyInHtmlListingTest.java
@Test public void storeOneFileAndVerifyItInParentDirectoryListing() throws Exception { final byte[] data = "this is a test".getBytes(); final ByteArrayInputStream stream = new ByteArrayInputStream(data); final String root = "/path/to/"; final String path = root + "foo.txt"; client.content().store(hosted, STORE, path, stream); final IndyClientHttp http = getHttp(); final HttpGet request = http.newRawGet(client.content().contentUrl(hosted, STORE, root)); request.addHeader("Accept", "text/html"); final CloseableHttpClient hc = http.newClient(); final CloseableHttpResponse response = hc.execute(request); final InputStream listing = response.getEntity().getContent(); final String html = IOUtils.toString(listing); // TODO: Charset!! final Document doc = Jsoup.parse(html); for (final Element item : doc.select("a.item-link")) { final String fname = item.text(); System.out.printf("Listing contains: '%s'\n", fname); final String href = item.attr("href"); final String expected = client.content().contentUrl(hosted, STORE, root, fname); assertThat(fname + " does not have a href", href, notNullValue()); assertThat(fname + " has incorrect link: '" + href + "' (" + href.getClass().getName() + ")\nshould be: '" + expected + "' (String)", href, equalTo(expected)); }/*from ww w . j a v a2s. c om*/ }
From source file:com.neatresults.mgnltweaks.ui.field.PropertyIdTransformer.java
@Override protected <T> Property<T> getOrCreateProperty(Class<T> type, boolean checkTypes) { String propertyName = definePropertyName(); Property<T> property = relatedFormItem.getItemProperty(propertyName); if (property == null) { if (relatedFormItem instanceof JcrPropertyAdapter) { JcrPropertyAdapter jcrProp = (JcrPropertyAdapter) relatedFormItem; try { String value = (String) PropertyUtil.getPropertyValueObject(jcrProp.getJcrItem().getParent(), jcrProp.getJcrItem().getName()); value = NeatUtil.templateIdToPath(value); Class aType = value.getClass(); // no way we can add property to a property, so assume property is the one we are looking for return new DefaultProperty(aType, value); } catch (RepositoryException e) { // ignore throw new RuntimeRepositoryException(e); }// w w w . j a v a 2 s .c o m } property = new DefaultProperty<T>(type, null); // here it will fail when propertyName is something else that value or jcrName relatedFormItem.addItemProperty(propertyName, property); } else if (checkTypes && !type.isAssignableFrom(property.getType())) { // solve MGNLUI-2494 // as we have type inconsistency (type of the jcr value is diff. of the definition one), try to convert the jcr type to the type coming from the definition. // get the value as String String stringValue = ((property.getValue() != null && StringUtils.isNotBlank(property.getValue().toString())) ? property.getValue().toString() : null); T value = null; try { // Convert the String value to the desired type. value = (T) DefaultPropertyUtil.createTypedValue(type, stringValue); } catch (Exception e) { // Ignore. In case of exception, set a null value. } property = new DefaultProperty<T>(type, value); // This will replace the previous property (with the wrong type) with the new one (correctly typed). relatedFormItem.addItemProperty(propertyName, property); } return property; }
From source file:org.commonjava.aprox.ftest.core.urls.StoreOneAndVerifyInHtmlListingTest.java
@Test public void storeOneFileAndVerifyItInParentDirectoryListing() throws Exception { final byte[] data = "this is a test".getBytes(); final ByteArrayInputStream stream = new ByteArrayInputStream(data); final String root = "/path/to/"; final String path = root + "foo.txt"; client.content().store(hosted, STORE, path, stream); final AproxClientHttp http = getHttp(); final HttpGet request = http.newRawGet(client.content().contentUrl(hosted, STORE, root)); request.addHeader("Accept", "text/html"); final CloseableHttpClient hc = http.newClient(); final CloseableHttpResponse response = hc.execute(request); final InputStream listing = response.getEntity().getContent(); final String html = IOUtils.toString(listing); // TODO: Charset!! final Document doc = Jsoup.parse(html); for (final Element item : doc.select("a.item-link")) { final String fname = item.text(); System.out.printf("Listing contains: '%s'\n", fname); final String href = item.attr("href"); final String expected = client.content().contentUrl(hosted, STORE, root, fname); assertThat(fname + " does not have a href", href, notNullValue()); assertThat(fname + " has incorrect link: '" + href + "' (" + href.getClass().getName() + ")\nshould be: '" + expected + "' (String)", href, equalTo(expected)); }/*w ww . j av a 2 s . co m*/ }
From source file:org.commonjava.aprox.folo.ftest.urls.StoreOneAndVerifyInHtmlListingTest.java
@Test public void storeOneFileAndVerifyItInParentDirectoryListing() throws Exception { final byte[] data = "this is a test".getBytes(); final ByteArrayInputStream stream = new ByteArrayInputStream(data); final String root = "/path/to/"; final String path = root + "foo.txt"; final String track = "track"; content.store(track, hosted, STORE, path, stream); final AproxClientHttp http = getHttp(); final HttpGet request = http.newRawGet(content.contentUrl(track, hosted, STORE, root)); request.addHeader("Accept", "text/html"); final CloseableHttpClient hc = http.newClient(); final CloseableHttpResponse response = hc.execute(request); final InputStream listing = response.getEntity().getContent(); final String html = IOUtils.toString(listing); // TODO: Charset!! final Document doc = Jsoup.parse(html); for (final Element item : doc.select("a.item-link")) { final String fname = item.text(); System.out.printf("Listing contains: '%s'\n", fname); final String href = item.attr("href"); final String expected = client.content().contentUrl(hosted, STORE, root, fname); assertThat(fname + " does not have a href", href, notNullValue()); assertThat(fname + " has incorrect link: '" + href + "' (" + href.getClass().getName() + ")\nshould be: '" + expected + "' (String)", href, equalTo(expected)); }//www . j a v a 2s . co m }
From source file:org.commonjava.indy.folo.ftest.urls.StoreOneAndVerifyInHtmlListingTest.java
@Test public void storeOneFileAndVerifyItInParentDirectoryListing() throws Exception { final byte[] data = "this is a test".getBytes(); final ByteArrayInputStream stream = new ByteArrayInputStream(data); final String root = "/path/to/"; final String path = root + "foo.txt"; final String track = "track"; content.store(track, hosted, STORE, path, stream); final IndyClientHttp http = getHttp(); final HttpGet request = http.newRawGet(content.contentUrl(track, hosted, STORE, root)); request.addHeader("Accept", "text/html"); final CloseableHttpClient hc = http.newClient(); final CloseableHttpResponse response = hc.execute(request); final InputStream listing = response.getEntity().getContent(); final String html = IOUtils.toString(listing); // TODO: Charset!! final Document doc = Jsoup.parse(html); for (final Element item : doc.select("a.item-link")) { final String fname = item.text(); System.out.printf("Listing contains: '%s'\n", fname); final String href = item.attr("href"); final String expected = client.content().contentUrl(hosted, STORE, root, fname); assertThat(fname + " does not have a href", href, notNullValue()); assertThat(fname + " has incorrect link: '" + href + "' (" + href.getClass().getName() + ")\nshould be: '" + expected + "' (String)", href, equalTo(expected)); }/* ww w .j av a 2s.c o m*/ }
From source file:edu.vt.middleware.servlet.filter.RequestMethodFilter.java
/** * Initialize this filter./*from www . ja va2 s .c o m*/ * * @param config <code>FilterConfig</code> */ public void init(final FilterConfig config) { final Enumeration<?> e = config.getInitParameterNames(); while (e.hasMoreElements()) { final String name = (String) e.nextElement(); final String value = config.getInitParameter(name); final StringTokenizer st = new StringTokenizer(name); final String methodName = st.nextToken(); Object[] args = null; Class<?>[] params = null; if (st.countTokens() > 0) { args = new Object[st.countTokens()]; params = new Class[st.countTokens()]; int i = 0; while (st.hasMoreTokens()) { final String token = st.nextToken(); args[i] = token; params[i++] = token.getClass(); } } try { this.servletMethods.put(methodName, ServletRequest.class.getMethod(methodName, params)); if (LOG.isDebugEnabled()) { LOG.debug("Found method " + methodName + " for ServletRequest"); } } catch (NoSuchMethodException ex) { if (LOG.isDebugEnabled()) { LOG.debug("Could not find method " + methodName + " for ServletRequest"); } } try { this.httpServletMethods.put(methodName, HttpServletRequest.class.getMethod(methodName, params)); if (LOG.isDebugEnabled()) { LOG.debug("Found method " + methodName + " for HttpServletRequest"); } } catch (NoSuchMethodException ex) { if (LOG.isDebugEnabled()) { LOG.debug("Could not find method " + methodName + " for HttpServletRequest"); } } this.arguments.put(methodName, args); this.patterns.put(methodName, Pattern.compile(value)); if (LOG.isDebugEnabled()) { if (this.arguments.get(methodName) != null) { if (LOG.isDebugEnabled()) { LOG.debug("Stored method name = " + methodName + ", pattern = " + value + " with these arguments " + Arrays.asList((Object[]) this.arguments.get(methodName))); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Stored method name = " + methodName + ", pattern = " + value + " with no arguments"); } } } } }