@Test
 public void canLookInMultipleClassDirectories() throws Exception {
   File newFile = createFileForClass(TestFakeProduct.class);
   File thisFile = InfinitestTestUtils.getFileForClass(getClass());
   Set<File> changedFiles = detector.findChangedFiles();
   assertThat(changedFiles, hasItem(newFile));
   assertThat(changedFiles, hasItem(thisFile));
 }
 /** When receiving NeighborSolicitation, updates location and IP. */
 @Test
 public void testReceiveNs() {
   testProcessor.process(new TestNsPacketContext(DEV4));
   HostDescription descr = providerService.added;
   assertThat(descr.location(), is(LOCATION2));
   assertThat(descr.hwAddress(), is(MAC2));
   assertThat(descr.ipAddress().toArray()[0], is(IP_ADDRESS2));
   assertThat(descr.vlan(), is(VLAN));
 }
 /** When receiving IPv4, updates location only. */
 @Test
 public void testReceiveIpv4() {
   testProcessor.process(new TestIpv4PacketContext(DEV1));
   HostDescription descr = providerService.added;
   assertThat(descr.location(), is(LOCATION));
   assertThat(descr.hwAddress(), is(MAC));
   assertThat(descr.ipAddress().size(), is(0));
   assertThat(descr.vlan(), is(VLAN));
 }
  @Test
  public void shouldFindRemovedFiles() throws Exception {
    File newFile = createFileForClass(TestFakeProduct.class);
    assertThat(detector.findChangedFiles(), hasItem(newFile));

    FileUtils.forceDelete(newFile);

    assertTrue(detector.filesWereRemoved());
    assertThat(detector.findChangedFiles(), not(hasItem(newFile)));
  }
  /* Tests if service correctly dispatches the request.
   */
  @Test
  public final void testService() throws Exception {

    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockServletConfig config = new MockServletConfig();

    ContentModuleServlet servlet = new ContentModuleServlet(cache);
    servlet.init(config);

    request.setServletPath("/com/globant/katari/jsmodule/view/image/a.png");
    request.setMethod("GET");
    servlet.service(request, response);

    assertThat(response.getStatus(), is(200));
    assertThat(response.getContentType(), is("image/png"));
  }
 @Test
 public void shouldFindChangedFiles() throws IOException {
   Set<File> files = detector.findChangedFiles();
   assertTrue("Should have found changed files on first run", files.size() > 0);
   assertThat(
       "TestFakeProduct should be in changed list",
       files,
       hasItem(getFileForClass(TestFakeProduct.class)));
   assertTrue(
       "FakeProduct should be in changed list",
       files.contains(getFileForClass(FakeProduct.class)));
   assertTrue("Should have no changed files now", detector.findChangedFiles().isEmpty());
 }
  /* Tests if service correctly dispatches the request for a bundled
   * file which was cached.
   */
  @Test
  public final void testService_bundlePathFile() throws Exception {

    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockServletConfig config = new MockServletConfig();

    String content = "var testFunction;";
    expect(cache.findContent("md5_hash_key.js")).andReturn(content);
    replay(cache);

    ContentModuleServlet servlet = new ContentModuleServlet(cache);
    servlet.init(config);

    request.setServletPath("/com/globant/katari/jsmodule/bundle/md5_hash_key.js");
    request.setMethod("GET");
    servlet.service(request, response);

    assertThat(response.getStatus(), is(200));
    assertThat(response.getContentType(), is("text/javascript"));
    assertThat(response.getContentAsString(), is(content));

    verify(cache);
  }