@Test public final void testContentModified() throws Exception { ServletHandler handler = new ServletHandler(); handler.addServletWithMapping(RESTServiceContentModified.class, "/*"); TestServer server = new TestServer(); server.addHandler(handler); try { server.startServer(); String destination = server.getUrl(); controller = TestRunners.newTestRunner(GetHTTP.class); controller.setProperty(GetHTTP.CONNECTION_TIMEOUT, "5 secs"); controller.setProperty(GetHTTP.URL, destination); controller.setProperty(GetHTTP.FILENAME, "testFile"); controller.setProperty(GetHTTP.ACCEPT_CONTENT_TYPE, "application/json"); controller.getStateManager().assertStateNotSet(GetHTTP.ETAG, Scope.LOCAL); controller.getStateManager().assertStateNotSet(GetHTTP.LAST_MODIFIED, Scope.LOCAL); controller.run(2); controller.getStateManager().assertStateNotEquals(GetHTTP.ETAG+":"+destination, "", Scope.LOCAL); controller.getStateManager().assertStateNotEquals(GetHTTP.LAST_MODIFIED+":"+destination, "Thu, 01 Jan 1970 00:00:00 GMT", Scope.LOCAL); controller.assertTransferCount(GetHTTP.REL_SUCCESS, 1); controller.getFlowFilesForRelationship(GetHTTP.REL_SUCCESS).get(0).assertAttributeEquals("gethttp.remote.source", "localhost"); controller.clearTransferState(); RESTServiceContentModified.IGNORE_ETAG = true; RESTServiceContentModified.IGNORE_LAST_MODIFIED = true; controller.run(2); controller.assertTransferCount(GetHTTP.REL_SUCCESS, 2); controller.clearTransferState(); RESTServiceContentModified.IGNORE_ETAG = false; controller.run(2); controller.assertTransferCount(GetHTTP.REL_SUCCESS, 0); RESTServiceContentModified.IGNORE_LAST_MODIFIED = false; RESTServiceContentModified.IGNORE_ETAG = true; controller.run(2); controller.assertTransferCount(GetHTTP.REL_SUCCESS, 0); RESTServiceContentModified.IGNORE_LAST_MODIFIED = true; RESTServiceContentModified.IGNORE_ETAG = false; RESTServiceContentModified.ETAG = 1; controller.run(2); controller.assertTransferCount(GetHTTP.REL_SUCCESS, 1); String eTagStateValue = controller.getStateManager().getState(Scope.LOCAL).get(GetHTTP.ETAG+":"+destination); assertEquals("1",GetHTTP.parseStateValue(eTagStateValue).getValue()); controller.clearTransferState(); RESTServiceContentModified.IGNORE_LAST_MODIFIED = false; RESTServiceContentModified.IGNORE_ETAG = true; RESTServiceContentModified.modificationDate = System.currentTimeMillis() / 1000 * 1000 + 5000; String lastMod = controller.getStateManager().getState(Scope.LOCAL).get(GetHTTP.LAST_MODIFIED+":"+destination); controller.run(2); controller.assertTransferCount(GetHTTP.REL_SUCCESS, 1); controller.getStateManager().assertStateNotEquals(GetHTTP.LAST_MODIFIED+":"+destination, lastMod, Scope.LOCAL); controller.clearTransferState(); } finally { server.shutdownServer(); } }
protected static Tuple<String, String> parseStateValue(String mapValue){ int indexOfColon = mapValue.indexOf(":"); String timestamp = mapValue.substring(0,indexOfColon); String value = mapValue.substring(indexOfColon+1); return new Tuple<>(timestamp,value); }
GetHTTP extends AbstractSessionFactoryProcessor { protected static Tuple<String, String> parseStateValue(String mapValue){ int indexOfColon = mapValue.indexOf(":"); String timestamp = mapValue.substring(0,indexOfColon); String value = mapValue.substring(indexOfColon+1); return new Tuple<>(timestamp,value); } }
GetHTTP extends AbstractSessionFactoryProcessor { protected static Tuple<String, String> parseStateValue(String mapValue){ int indexOfColon = mapValue.indexOf(":"); String timestamp = mapValue.substring(0,indexOfColon); String value = mapValue.substring(indexOfColon+1); return new Tuple<>(timestamp,value); }  }
GetHTTP extends AbstractSessionFactoryProcessor { protected static Tuple<String, String> parseStateValue(String mapValue){ int indexOfColon = mapValue.indexOf(":"); String timestamp = mapValue.substring(0,indexOfColon); String value = mapValue.substring(indexOfColon+1); return new Tuple<>(timestamp,value); }  @Override Set<Relationship> getRelationships(); @Override void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue); @OnScheduled void onScheduled(final ProcessContext context); @Override void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory); }
GetHTTP extends AbstractSessionFactoryProcessor { protected static Tuple<String, String> parseStateValue(String mapValue){ int indexOfColon = mapValue.indexOf(":"); String timestamp = mapValue.substring(0,indexOfColon); String value = mapValue.substring(indexOfColon+1); return new Tuple<>(timestamp,value); }  @Override Set<Relationship> getRelationships(); @Override void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue); @OnScheduled void onScheduled(final ProcessContext context); @Override void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory); static final String HEADER_IF_NONE_MATCH; static final String HEADER_IF_MODIFIED_SINCE; static final String HEADER_ACCEPT; static final String HEADER_LAST_MODIFIED; static final String HEADER_ETAG; static final int NOT_MODIFIED; static final PropertyDescriptor URL; static final PropertyDescriptor FOLLOW_REDIRECTS; static final PropertyDescriptor CONNECTION_TIMEOUT; static final PropertyDescriptor ACCEPT_CONTENT_TYPE; static final PropertyDescriptor DATA_TIMEOUT; static final PropertyDescriptor FILENAME; static final PropertyDescriptor USERNAME; static final PropertyDescriptor PASSWORD; static final PropertyDescriptor USER_AGENT; static final PropertyDescriptor SSL_CONTEXT_SERVICE; static final PropertyDescriptor PROXY_HOST; static final PropertyDescriptor PROXY_PORT; static final String DEFAULT_COOKIE_POLICY_STR; static final String STANDARD_COOKIE_POLICY_STR; static final String STRICT_COOKIE_POLICY_STR; static final String NETSCAPE_COOKIE_POLICY_STR; static final String IGNORE_COOKIE_POLICY_STR; static final AllowableValue DEFAULT_COOKIE_POLICY; static final AllowableValue STANDARD_COOKIE_POLICY; static final AllowableValue STRICT_COOKIE_POLICY; static final AllowableValue NETSCAPE_COOKIE_POLICY; static final AllowableValue IGNORE_COOKIE_POLICY; static final PropertyDescriptor REDIRECT_COOKIE_POLICY; static final Relationship REL_SUCCESS; static final String LAST_MODIFIED_DATE_PATTERN_RFC1123; }