text:
namespace ash {

namespace {

ShelfWidget* GetShelfWidget() {
  return Shelf::ForPrimaryDisplay()->shelf_widget();
}

ShelfLayoutManager* GetShelfLayoutManager() {
  return GetShelfWidget()->shelf_layout_manager();
}

} // namespace

typedef test::AshTestBase ShelfWidgetTest;

void TestLauncherAlignment(aura::Window* root,
                           wm::ShelfAlignment alignment,
                           const std::string& expected) {
  Shell::GetInstance()->SetShelfAlignment(alignment, root);
  display::Screen* screen = display::Screen::GetScreen();
  EXPECT_EQ(expected,
            screen->GetDisplayNearestWindow(root).work_area().ToString());
}

#if defined(OS_WIN) && !defined(USE_ASH)
// TODO(msw): Broken on Windows. http://crbug.com/584038
#define MAYBE_TestAlignment DISABLED_TestAlignment
#else
#define MAYBE_TestAlignment TestAlignment
#endif
TEST_F(ShelfWidgetTest, MAYBE_TestAlignment) {
  Shelf* shelf = Shelf::ForPrimaryDisplay();
  UpdateDisplay("400x400");
  ASSERT_TRUE(shelf);
  {
    SCOPED_TRACE("Single Bottom");
    TestLauncherAlignment(Shell::GetPrimaryRootWindow(),
                          wm::SHELF_ALIGNMENT_BOTTOM, "0,0 400x353");
  }
  {
    SCOPED_TRACE("Single Locked");
    TestLauncherAlignment(Shell::GetPrimaryRootWindow(),
                          wm::SHELF_ALIGNMENT_BOTTOM_LOCKED, "0,0 400x353");
  }
  {
    SCOPED_TRACE("Single Right");
    TestLauncherAlignment(Shell::GetPrimaryRootWindow(),
                          wm::SHELF_ALIGNMENT_RIGHT, "0,0 353x400");
  }
  {
    SCOPED_TRACE("Single Left");
    TestLauncherAlignment(Shell::GetPrimaryRootWindow(),
                          wm::SHELF_ALIGNMENT_LEFT, "47,0 353x400");
  }
  if (!SupportsMultipleDisplays())
    return;

  UpdateDisplay("300x300,500x500");
  aura::Window::Windows root_windows = Shell::GetAllRootWindows();
  {
    SCOPED_TRACE("Primary Bottom");
    TestLauncherAlignment(root_windows[0], wm::SHELF_ALIGNMENT_BOTTOM,
                          "0,0 300x253");
  }
  {
    SCOPED_TRACE("Primary Locked");
    TestLauncherAlignment(root_windows[0], wm::SHELF_ALIGNMENT_BOTTOM_LOCKED,
                          "0,0 300x253");
  }
  {
    SCOPED_TRACE("Primary Right");
    TestLauncherAlignment(root_windows[0], wm::SHELF_ALIGNMENT_RIGHT,
                          "0,0 253x300");
  }
  {
    SCOPED_TRACE("Primary Left");
    TestLauncherAlignment(root_windows[0], wm::SHELF_ALIGNMENT_LEFT,
                          "47,0 253x300");
  }
  {
    SCOPED_TRACE("Secondary Bottom");
    TestLauncherAlignment(root_windows[1], wm::SHELF_ALIGNMENT_BOTTOM,
                          "300,0 500x453");
  }
  {
    SCOPED_TRACE("Secondary Locked");
    TestLauncherAlignment(root_windows[1], wm::SHELF_ALIGNMENT_BOTTOM_LOCKED,
                          "300,0 500x453");
  }
  {
    SCOPED_TRACE("Secondary Right");
    TestLauncherAlignment(root_windows[1], wm::SHELF_ALIGNMENT_RIGHT,
                          "300,0 453x500");
  }
  {
    SCOPED_TRACE("Secondary Left");
    TestLauncherAlignment(root_windows[1], wm::SHELF_ALIGNMENT_LEFT,
                          "347,0 453x500");
  }
}

// Makes sure the shelf is initially sized correctly.
TEST_F(ShelfWidgetTest, LauncherInitiallySized) {
  ShelfWidget* shelf_widget = GetShelfWidget();
  Shelf* shelf = shelf_widget->shelf();
  ASSERT_TRUE(shelf);
  ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager();
  ASSERT_TRUE(shelf_layout_manager);
  ASSERT_TRUE(shelf_widget->status_area_widget());
  int status_width = shelf_widget->status_area_widget()->
      GetWindowBoundsInScreen().width();
  // Test only makes sense if the status is > 0, which it better be.
  EXPECT_GT(status_width, 0);
  EXPECT_EQ(status_width, shelf_widget->GetContentsView()->width() -
            test::ShelfTestAPI(shelf).shelf_view()->width());
}

// Verifies when the shell is deleted with a full screen window we don't crash.
TEST_F(ShelfWidgetTest, DontReferenceShelfAfterDeletion) {
  views::Widget* widget = new views::Widget;
  views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
  params.bounds = gfx::Rect(0, 0, 200, 200);
  params.context = CurrentContext();
  // Widget is now owned by the parent window.
  widget->Init(params);
  widget->SetFullscreen(true);
}

#if defined(OS_CHROMEOS)
// Verifies shelf is created with correct size after user login and when its
// container and status widget has finished sizing.
// See http://crbug.com/252533
TEST_F(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) {
  SetUserLoggedIn(false);
  UpdateDisplay("300x200,400x300");

  ShelfWidget* shelf_widget = NULL;
  Shell::RootWindowControllerList controllers(
      Shell::GetAllRootWindowControllers());
  for (Shell::RootWindowControllerList::const_iterator i = controllers.begin();
       i != controllers.end();
       ++i) {
    if (!(*i)->shelf()->shelf()) {
      shelf_widget = (*i)->shelf();
      break;
    }
  }
  ASSERT_TRUE(shelf_widget != NULL);

  SetUserLoggedIn(true);
  Shell::GetInstance()->CreateShelf();

  Shelf* shelf = shelf_widget->shelf();
  ASSERT_TRUE(shelf != NULL);

  const int status_width =
      shelf_widget->status_area_widget()->GetWindowBoundsInScreen().width();
  EXPECT_GT(status_width, 0);
  EXPECT_EQ(status_width,
            shelf_widget->GetContentsView()->width() -
                test::ShelfTestAPI(shelf).shelf_view()->width());
}
#endif  // defined(OS_CHROMEOS)

// Tests that the shelf lets mouse-events close to the edge fall through to the
// window underneath.
TEST_F(ShelfWidgetTest, ShelfEdgeOverlappingWindowHitTestMouse) {
  ShelfWidget* shelf_widget = GetShelfWidget();
  gfx::Rect shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
  EXPECT_TRUE(!shelf_bounds.IsEmpty());
  ShelfLayoutManager* shelf_layout_manager =
      shelf_widget->shelf_layout_manager();
  ASSERT_TRUE(shelf_layout_manager);
  EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state());

  // Create a Widget which overlaps the shelf in both left and bottom
  // alignments.
  const int kOverlapSize = 15;
  const int kWindowHeight = 200;
  const int kWindowWidth = 200;
  views::Widget* widget = new views::Widget;
  views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
  params.bounds = gfx::Rect(shelf_bounds.height() - kOverlapSize,
                            shelf_bounds.y() - kWindowHeight + kOverlapSize,
                            kWindowWidth, kWindowHeight);
  params.context = CurrentContext();
  // Widget is now owned by the parent window.
  widget->Init(params);
  widget->Show();
  gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen();
  EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds));

  ui::EventTarget* root = widget->GetNativeWindow()->GetRootWindow();
  ui::EventTargeter* targeter = root->GetEventTargeter();
  {
    // Create a mouse-event targeting the top of the shelf widget. The
    // window-targeter should find |widget| as the target (instead of the
    // shelf).
    gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1);
    ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
                         ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
    ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
    EXPECT_EQ(widget->GetNativeWindow(), target);
  }

  // Change shelf alignment to verify that the targeter insets are updated.
  shelf_layout_manager->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
  shelf_layout_manager->LayoutShelf();
  shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
  {
    // Create a mouse-event targeting the right edge of the shelf widget. The
    // window-targeter should find |widget| as the target (instead of the
    // shelf).
    gfx::Point event_location(shelf_bounds.right() - 1, widget_bounds.y() + 5);
    ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
                         ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
    ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
    EXPECT_EQ(widget->GetNativeWindow(), target);
  }

  // Now restore shelf alignment (bottom) and auto-hide (hidden) the shelf.
  shelf_layout_manager->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM);
  shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
  shelf_layout_manager->LayoutShelf();
  EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state());
  EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
  shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
  EXPECT_TRUE(!shelf_bounds.IsEmpty());

  // Move |widget| so it still overlaps the shelf.
  widget->SetBounds(gfx::Rect(0,
                              shelf_bounds.y() - kWindowHeight + kOverlapSize,
                              kWindowWidth, kWindowHeight));
  widget_bounds = widget->GetWindowBoundsInScreen();
  EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds));
  {
    // Create a mouse-event targeting the top of the shelf widget. This time,
    // window-target should find the shelf as the target.
    gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1);
    ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
                         ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
    ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
    EXPECT_EQ(shelf_widget->GetNativeWindow(), target);
  }
}

// Tests that the shelf has a slightly larger hit-region for touch-events when
// it's in the auto-hidden state.
TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) {
  ShelfWidget* shelf_widget = GetShelfWidget();
  gfx::Rect shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
  EXPECT_TRUE(!shelf_bounds.IsEmpty());
  ShelfLayoutManager* shelf_layout_manager =
      shelf_widget->shelf_layout_manager();
  ASSERT_TRUE(shelf_layout_manager);
  EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state());

  // Create a widget to make sure that the shelf does auto-hide.
  views::Widget* widget = new views::Widget;
  views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
  params.bounds = gfx::Rect(0, 0, 200, 200);
  params.context = CurrentContext();
  // Widget is now owned by the parent window.
  widget->Init(params);
  widget->Show();

  ui::EventTarget* root = shelf_widget->GetNativeWindow()->GetRootWindow();
  ui::EventTargeter* targeter = root->GetEventTargeter();
  // Touch just over the shelf. Since the shelf is visible, the window-targeter
  // should not find the shelf as the target.
  {
    gfx::Point event_location(20, shelf_bounds.y() - 1);
    ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0,
                         ui::EventTimeForNow());
    EXPECT_NE(shelf_widget->GetNativeWindow(),
              targeter->FindTargetForEvent(root, &touch));
  }

  // Now auto-hide (hidden) the shelf.
  shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
  shelf_layout_manager->LayoutShelf();
  EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state());
  EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
  shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
  EXPECT_TRUE(!shelf_bounds.IsEmpty());

  // Touch just over the shelf again. This time, the targeter should find the
  // shelf as the target.
  {
    gfx::Point event_location(20, shelf_bounds.y() - 1);
    ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0,
                         ui::EventTimeForNow());
    EXPECT_EQ(shelf_widget->GetNativeWindow(),
              targeter->FindTargetForEvent(root, &touch));
  }
}

namespace {

// A TestShelfDelegate that sets the shelf alignment and auto hide behavior in
// OnShelfCreated, to simulate ChromeLauncherController's behavior.
class TestShelfDelegate : public ShelfDelegate {
 public:
  TestShelfDelegate(wm::ShelfAlignment initial_alignment,
                    ShelfAutoHideBehavior initial_auto_hide_behavior)
      : initial_alignment_(initial_alignment),
        initial_auto_hide_behavior_(initial_auto_hide_behavior) {}
  ~TestShelfDelegate() override {}

  // ShelfDelegate implementation.
  void OnShelfCreated(Shelf* shelf) override {
    shelf->SetAlignment(initial_alignment_);
    shelf->SetAutoHideBehavior(initial_auto_hide_behavior_);
  }
  void OnShelfDestroyed(Shelf* shelf) override {}
  void OnShelfAlignmentChanged(Shelf* shelf) override {}
  void OnShelfAutoHideBehaviorChanged(Shelf* shelf) override {}
  ShelfID GetShelfIDForAppID(const std::string& app_id) override { return 0; }
  bool HasShelfIDToAppIDMapping(ShelfID id) const override { return false; }
  const std::string& GetAppIDForShelfID(ShelfID id) override {
    return base::EmptyString();
  }
  void PinAppWithID(const std::string& app_id) override {}
  bool IsAppPinned(const std::string& app_id) override { return false; }
  void UnpinAppWithID(const std::string& app_id) override {}

 private:
  wm::ShelfAlignment initial_alignment_;
  ShelfAutoHideBehavior initial_auto_hide_behavior_;

  DISALLOW_COPY_AND_ASSIGN(TestShelfDelegate);
};

// A TestShellDelegate that creates a TestShelfDelegate with initial values.
class ShelfWidgetTestShellDelegate : public test::TestShellDelegate {
 public:
  ShelfWidgetTestShellDelegate() {}
  ~ShelfWidgetTestShellDelegate() override {}

  // test::TestShellDelegate
  ShelfDelegate* CreateShelfDelegate(ShelfModel* model) override {
    return new TestShelfDelegate(initial_alignment_,
                                 initial_auto_hide_behavior_);
  }

  void set_initial_alignment(wm::ShelfAlignment alignment) {
    initial_alignment_ = alignment;
  }

  void set_initial_auto_hide_behavior(ShelfAutoHideBehavior behavior) {
    initial_auto_hide_behavior_ = behavior;
  }

 private:
  wm::ShelfAlignment initial_alignment_ = wm::SHELF_ALIGNMENT_BOTTOM;
  ShelfAutoHideBehavior initial_auto_hide_behavior_ =
      SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
  DISALLOW_COPY_AND_ASSIGN(ShelfWidgetTestShellDelegate);
};

class ShelfWidgetTestWithDelegate : public ShelfWidgetTest {
 public:
  ShelfWidgetTestWithDelegate() { set_start_session(false); }
  ~ShelfWidgetTestWithDelegate() override {}

  // ShelfWidgetTest:
  void SetUp() override {
    shelf_widget_test_shell_delegate_ = new ShelfWidgetTestShellDelegate;
    ash_test_helper()->set_test_shell_delegate(
        shelf_widget_test_shell_delegate_);
    ShelfWidgetTest::SetUp();
  }

  void TestCreateShelfWithInitialValues(
      wm::ShelfAlignment initial_alignment,
      ShelfAutoHideBehavior initial_auto_hide_behavior,
      ShelfVisibilityState expected_shelf_visibility_state,
      ShelfAutoHideState expected_shelf_auto_hide_state) {
    shelf_widget_test_shell_delegate_->set_initial_alignment(initial_alignment);
    shelf_widget_test_shell_delegate_->set_initial_auto_hide_behavior(
        initial_auto_hide_behavior);
    SetUserLoggedIn(true);
    SetSessionStarted(true);

    ShelfWidget* shelf_widget = GetShelfWidget();
    ASSERT_NE(nullptr, shelf_widget);
    Shelf* shelf = shelf_widget->shelf();
    ASSERT_NE(nullptr, shelf);
    ShelfLayoutManager* shelf_layout_manager =
        shelf_widget->shelf_layout_manager();
    ASSERT_NE(nullptr, shelf_layout_manager);

    EXPECT_EQ(initial_alignment, shelf_layout_manager->GetAlignment());
    EXPECT_EQ(initial_auto_hide_behavior,
              shelf_layout_manager->auto_hide_behavior());
    EXPECT_EQ(expected_shelf_visibility_state,
              shelf_layout_manager->visibility_state());
    EXPECT_EQ(expected_shelf_auto_hide_state,
              shelf_layout_manager->auto_hide_state());
  }

 private:
  ShelfWidgetTestShellDelegate* shelf_widget_test_shell_delegate_;
  DISALLOW_COPY_AND_ASSIGN(ShelfWidgetTestWithDelegate);
};

}  // namespace

TEST_F(ShelfWidgetTestWithDelegate, CreateAutoHideAlwaysShelf) {
  // The actual auto hide state is shown because there are no open windows.
  TestCreateShelfWithInitialValues(wm::SHELF_ALIGNMENT_BOTTOM,
                                   SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
                                   SHELF_AUTO_HIDE, SHELF_AUTO_HIDE_SHOWN);
}

TEST_F(ShelfWidgetTestWithDelegate, CreateAutoHideNeverShelf) {
  // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior.
  TestCreateShelfWithInitialValues(wm::SHELF_ALIGNMENT_LEFT,
                                   SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
                                   SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN);
}

TEST_F(ShelfWidgetTestWithDelegate, CreateAutoHideAlwaysHideShelf) {
  // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior.
  TestCreateShelfWithInitialValues(wm::SHELF_ALIGNMENT_RIGHT,
                                   SHELF_AUTO_HIDE_ALWAYS_HIDDEN, SHELF_HIDDEN,
                                   SHELF_AUTO_HIDE_HIDDEN);
}

TEST_F(ShelfWidgetTestWithDelegate, CreateLockedShelf) {
  // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior.
  TestCreateShelfWithInitialValues(wm::SHELF_ALIGNMENT_BOTTOM_LOCKED,
                                   SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
                                   SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN);
}

}  // namespace ash


text:
package io.mola.galimatias;

import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;

import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;

import static org.fest.assertions.Assertions.assertThat;
import static org.junit.Assume.*;

@RunWith(Theories.class)
public class URLTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Theory
    public void parse_url_whatwg(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                     TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        final URL parsedURL = URL.parse(testURL.parsedBaseURL, testURL.rawURL);
        assertThat(parsedURL).isEqualTo(testURL.parsedURL);
        assertThat(parsedURL.scheme()).isEqualTo(testURL.parsedURL.scheme());
        assertThat(parsedURL.schemeData()).isEqualTo(testURL.parsedURL.schemeData());
        assertThat(parsedURL.username()).isEqualTo(testURL.parsedURL.username());
        assertThat(parsedURL.password()).isEqualTo(testURL.parsedURL.password());
        assertThat(parsedURL.host()).isEqualTo(testURL.parsedURL.host());
        assertThat(parsedURL.port()).isEqualTo(testURL.parsedURL.port());
        assertThat(parsedURL.path()).isEqualTo(testURL.parsedURL.path());
        assertThat(parsedURL.query()).isEqualTo(testURL.parsedURL.query());
        assertThat(parsedURL.fragment()).isEqualTo(testURL.parsedURL.fragment());
        assertThat(parsedURL.isHierarchical()).isEqualTo(testURL.parsedURL.isHierarchical());
        assertThat(parsedURL.isOpaque()).isEqualTo(testURL.parsedURL.isOpaque());
    }

    @Theory
    public void parse_url_bad_whatwg(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                         TestURL testURL) throws GalimatiasParseException {
        assumeTrue(testURL.parsedURL == null);
        thrown.expect(GalimatiasParseException.class);
        URL.parse(testURL.parsedBaseURL, testURL.rawURL);
    }

    @Theory
    public void parse_url_host_whatwg(final @TestURL.TestURLs(dataset = TestURL.DATASETS.HOST_WHATWG)
                                          TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        final URL parsedURL = URL.parse(testURL.parsedBaseURL, testURL.rawURL);
        assertThat(parsedURL.host()).isEqualTo(testURL.parsedURL.host());
    }

    @Theory
    public void parse_url_bad_host_whatwg(final @TestURL.TestURLs(dataset = TestURL.DATASETS.HOST_WHATWG)
                                              TestURL testURL) throws GalimatiasParseException {
        assumeTrue(testURL.parsedURL == null);
        thrown.expect(GalimatiasParseException.class);
        URL.parse(testURL.parsedBaseURL, testURL.rawURL);
    }

    @Theory
    public void userInfoWithUsernameAndPassword(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                                    TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeNotNull(testURL.parsedURL.username(), testURL.parsedURL.password());
        assertThat(testURL.parsedURL.userInfo())
                .isEqualTo(String.format("%s:%s", testURL.parsedURL.username(), testURL.parsedURL.password()));
    }

    @Theory
    public void userInfoWithUsernameOnly(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                             TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeNotNull(testURL.parsedURL.username());
        assumeTrue(testURL.parsedURL.password() == null);
        assertThat(testURL.parsedURL.userInfo()).isEqualTo(testURL.parsedURL.username());
    }

    @Theory
    public void userInfoWithPasswordOnly(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                             TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeNotNull(testURL.parsedURL.password());
        assumeTrue("".equals(testURL.parsedURL.username()));
        assertThat(testURL.parsedURL.userInfo()).isEqualTo(":" + testURL.parsedURL.password());
    }

    @Theory
    public void withSchemeFromHierarchical(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                               TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isHierarchical());
        for (final String scheme : new String[] { "http", "https", "ws", "wss", "ftp", "file" }) {
            assertThat(testURL.parsedURL.withScheme(scheme).scheme()).isEqualTo(scheme);
        }
    }

    @Theory
    public void withNullScheme(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                   TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        thrown.expect(NullPointerException.class);
        testURL.parsedURL.withScheme(null);
    }

    @Theory
    public void withEmptyScheme(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                    TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        thrown.expect(GalimatiasParseException.class);
        testURL.parsedURL.withScheme("");
    }

    @Theory
    public void withSchemeFromOpaque(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                         TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isOpaque());
        for (final String scheme : new String[] { "data", "foobar" }) {
            assertThat(testURL.parsedURL.withScheme(scheme).scheme()).isEqualTo(scheme);
        }
    }

    @Theory
    public void withUsername(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                 TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isHierarchical());
        assertThat(testURL.parsedURL.withUsername("user").username()).isEqualTo("user");
        assertThat(testURL.parsedURL.withUsername(null).username()).isEqualTo("");
    }

    @Theory
    public void withUsernameOpaque(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                       TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isOpaque());
        thrown.expect(GalimatiasParseException.class);
        testURL.parsedURL.withUsername("user");
    }

    @Theory
    public void withPassword(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                 TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isHierarchical());
        assertThat(testURL.parsedURL.withPassword("password").password()).isEqualTo("password");
        assertThat(testURL.parsedURL.withPassword(null).password()).isNull();
    }

    @Theory
    public void withPasswordOpaque(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                       TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isOpaque());
        thrown.expect(GalimatiasParseException.class);
        testURL.parsedURL.withPassword("password");
    }

    @Theory
    public void withHost(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                             TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isHierarchical());
        assertThat(testURL.parsedURL.withHost("example.com").host()).isEqualTo(Host.parseHost("example.com"));
    }

    @Theory
    public void withHostNoHierarchical(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                           TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(!testURL.parsedURL.isHierarchical());
        thrown.expect(GalimatiasParseException.class);
        testURL.parsedURL.withHost("example.com");
    }

    @Theory
    public void withHostNoHierarchical2(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                       TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(!testURL.parsedURL.isHierarchical());
        final Host host = Host.parseHost("example.com");
        thrown.expect(GalimatiasParseException.class);
        testURL.parsedURL.withHost(host);
    }

    @Theory
    public void withNullHost(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                 TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isHierarchical());
        thrown.expect(NullPointerException.class);
        testURL.parsedURL.withHost((String)null);
    }

    @Theory
    public void withNullHost2(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                             TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isHierarchical());
        thrown.expect(NullPointerException.class);
        testURL.parsedURL.withHost((Host)null);
    }

    @Theory
    public void withHostOpaque(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                   TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isOpaque());
        thrown.expect(GalimatiasParseException.class);
        testURL.parsedURL.withHost("example.com");
    }

    @Theory
    public void withPort(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                             TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isHierarchical());
        assertThat(testURL.parsedURL.withPort(80).port()).isEqualTo(80);
    }

    @Theory
    public void withPortOpaque(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                   TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isOpaque());
        thrown.expect(GalimatiasParseException.class);
        testURL.parsedURL.withPort(80);
    }

    @Theory
    public void withPath(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                             TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isHierarchical());
        assertThat(testURL.parsedURL.withPath("/foo/bar").path()).isEqualTo("/foo/bar");
    }

    @Theory
    public void withPathOpaque(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                   TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isOpaque());
        thrown.expect(GalimatiasParseException.class);
        testURL.parsedURL.withPath("/path");
    }

    @Theory
    public void withQuery(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                              TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assertThat(testURL.parsedURL.withQuery("query").query()).isEqualTo("query");
        assertThat(testURL.parsedURL.withQuery("?query").query()).isEqualTo("query");
        assertThat(testURL.parsedURL.withQuery(null).query()).isEqualTo(null);
    }

    @Theory
    public void withFragment(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                 TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assertThat(testURL.parsedURL.withFragment("fragment").fragment()).isEqualTo("fragment");
        assertThat(testURL.parsedURL.withFragment("#fragment").fragment()).isEqualTo("fragment");
        assertThat(testURL.parsedURL.withFragment(null).fragment()).isEqualTo(null);
    }

    @Theory
    public void getAuthorityNullOnOpaque(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                             TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isOpaque());
        assertThat(testURL.parsedURL.authority()).isNull();
    }

    @Theory
    public void getAuthorityNonNullOnHierarchical(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                                      TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.isHierarchical());
        assumeFalse(testURL.parsedURL.scheme().equals("file"));
        assertThat(testURL.parsedURL.authority()).isNotNull();
    }

    @Theory
    public void toFromJavaURI(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                  TestURL testURL) throws GalimatiasParseException, URISyntaxException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(isConvertibleToJavaURI(testURL.parsedURL));
        final URL oneRound = URL.fromJavaURI(testURL.parsedURL.toJavaURI());
        final URL twoRound = URL.fromJavaURI(oneRound.toJavaURI());
        assertThat(oneRound).isEqualTo(twoRound);
    }

    @Theory
    public void toFromJavaURIException(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                              TestURL testURL) throws GalimatiasParseException, URISyntaxException {
        assumeNotNull(testURL.parsedURL);
        assumeFalse(isConvertibleToJavaURI(testURL.parsedURL));
        thrown.expect(URISyntaxException.class);
        testURL.parsedURL.toJavaURI();
    }

    private static boolean isConvertibleToJavaURI(final URL url) {
        if (url.isOpaque() && "//".equals(url.schemeData())) {
            return false;
        }
        if (url.isHierarchical() && url.host() != null && (url.host() instanceof Domain)) {
            final Domain domain = (Domain) url.host();
            return URLUtils.isASCIIAlpha(domain.labels().get(domain.labels().size() - 1).charAt(0));
        }
        return true;
    }

    private static final List<String> JAVA_URL_PROTOCOLS = Arrays.asList(
            "http", "https", "ftp", "file", "jar"
    );

    @Theory
    public void toFromJavaURL(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
                                  TestURL testURL) throws GalimatiasParseException, MalformedURLException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(JAVA_URL_PROTOCOLS.contains(testURL.parsedURL.scheme()));
        final java.net.URL toURL = testURL.parsedURL.toJavaURL();
        assertThat(testURL.parsedURL).isEqualTo(URL.fromJavaURL(toURL));
    }

    @Test
    public void equivalences() throws GalimatiasParseException {
        assertThat(URL.parse("http://example.com/")).isNotEqualTo("http://example.com/");

        assertThat(URL.parse("http://a.com")).isEqualTo(URL.parse("http://a.com/"));
        assertThat(URL.parse("http://a.com").hashCode()).isEqualTo(URL.parse("http://a.com/").hashCode());

        assertThat(URL.parse("http://a.com/")).isNotEqualTo(URL.parse("http://a.com/?"));
        assertThat(URL.parse("http://a.com/").hashCode()).isNotEqualTo(URL.parse("http://a.com/?").hashCode());
        assertThat(URL.parse("http://a.com/?").withQuery(null)).isEqualTo(URL.parse("http://a.com/"));
        assertThat(URL.parse("http://a.com/").withQuery("")).isEqualTo(URL.parse("http://a.com/?"));

        assertThat(URL.parse("http://a.com/")).isNotEqualTo(URL.parse("http://a.com/#"));
        assertThat(URL.parse("http://a.com/").hashCode()).isNotEqualTo(URL.parse("http://a.com/#").hashCode());
        assertThat(URL.parse("http://a.com/#").withFragment(null)).isEqualTo(URL.parse("http://a.com/"));
        assertThat(URL.parse("http://a.com/").withFragment("")).isEqualTo(URL.parse("http://a.com/#"));

    }

    @Test
    public void reduceObjectCreation() throws GalimatiasParseException {
        URL original = URL.parse("http://a.com/?foo");
        assertThat(original == original.withQuery("foo"));
        original = URL.parse("http://a.com/#foo");
        assertThat(original == original.withFragment("foo"));
    }

    @Test(expected = NullPointerException.class)
    public void schemeCannotBeNull() throws GalimatiasParseException {
        new URL(null, null, null, null, Host.parseHost("example.com"), -1, "/", null, null, true);
    }

    @Test
    public void internalURLParserChecks() throws GalimatiasParseException {
        // Trying to override scheme without ending with colon should have no effect
        // as per WHATWG spec.
        assertThat(new URLParser("ws", URL.parse("http://example.com"), URLParser.ParseURLState.SCHEME).parse())
                .isEqualTo(URL.parse("http://example.com"));

        assertThat(new URLParser("other.com:222", URL.parse("http://example.com"), URLParser.ParseURLState.HOST).parse())
                .isEqualTo(URL.parse("http://other.com"));
        assertThat(new URLParser("other.com/foo", URL.parse("http://example.com"), URLParser.ParseURLState.HOST).parse())
                .isEqualTo(URL.parse("http://other.com"));
        assertThat(new URLParser("other.com?foo", URL.parse("http://example.com"), URLParser.ParseURLState.HOST).parse())
                .isEqualTo(URL.parse("http://other.com"));
        assertThat(new URLParser("other.com#foo", URL.parse("http://example.com"), URLParser.ParseURLState.HOST).parse())
                .isEqualTo(URL.parse("http://other.com"));

        assertThat(new URLParser("22", URL.parse("http://example.com"), URLParser.ParseURLState.PORT).parse())
                .isEqualTo(URL.parse("http://example.com:22"));
    }

    @Test
    public void relativizeChecks() throws GalimatiasParseException {
        URL base = URL.parse("about:blank");
        assertThat(base.relativize(URL.parse("about:blank/foo"))).isEqualTo("about:blank/foo");
        assertThat(base.relativize(URL.parse("http://example.com/"))).isEqualTo("http://example.com/");

        base = URL.parse("http://example.com/");
        assertThat(base.relativize(URL.parse("about:blank"))).isEqualTo("about:blank");
        assertThat(base.relativize(URL.parse("https://example.com/"))).isEqualTo("https://example.com/");
        assertThat(base.relativize(URL.parse("http://other.com/"))).isEqualTo("http://other.com/");
        assertThat(base.relativize(URL.parse("http://user@example.com/"))).isEqualTo("http://user@example.com/");
        assertThat(base.relativize(URL.parse("http://user:pass@example.com/"))).isEqualTo("http://user:pass@example.com/");
        assertThat(base.relativize(URL.parse("http://:pass@example.com/"))).isEqualTo("http://:pass@example.com/");
        assertThat(base.relativize(URL.parse("http://example.com/foo"))).isEqualTo("foo");
        assertThat(base.relativize(URL.parse("http://example.com/foo?bar"))).isEqualTo("foo?bar");
        assertThat(base.relativize(URL.parse("http://example.com/foo#bar"))).isEqualTo("foo#bar");
        assertThat(base.relativize(URL.parse("http://example.com/foo?bar#baz"))).isEqualTo("foo?bar#baz");

        base = URL.parse("http://example.com/foo?bar#baz");
        assertThat(base.relativize(URL.parse("http://example.com/bar"))).isEqualTo("http://example.com/bar");
        assertThat(base.relativize(URL.parse("http://example.com/foo/bar"))).isEqualTo("bar");
        assertThat(base.relativize(URL.parse("http://example.com/foo/bar"))).isEqualTo("bar");
        assertThat(base.relativize(URL.parse("http://example.com/foo"))).isEqualTo("");
        assertThat(base.relativize(URL.parse("http://example.com/foo/"))).isEqualTo("");
        assertThat(base.relativize(URL.parse("http://example.com/foo?bar#baz"))).isEqualTo("?bar#baz");

        base = URL.parse("http://example.com/foo/?bar#baz");
        assertThat(base.relativize(URL.parse("http://example.com/foo"))).isEqualTo("http://example.com/foo");
        assertThat(base.relativize(URL.parse("http://example.com/foo/"))).isEqualTo("");
        assertThat(base.relativize(URL.parse("http://example.com/foo/?bar#baz"))).isEqualTo("?bar#baz");

        base = URL.parse("coap://example.com/foo/?bar#baz");
        assertThat(base.relativize(URL.parse("coap://example.com/foo"))).isEqualTo("coap://example.com/foo");
        assertThat(base.relativize(URL.parse("coap://example.com/foo/"))).isEqualTo("");
        assertThat(base.relativize(URL.parse("coap://example.com/foo/?bar#baz"))).isEqualTo("?bar#baz");

        base = URL.parse("file:///etc/fstab");
        assertThat(base.relativize(URL.parse("file://localhost/etc/fstab"))).isEqualTo("file://localhost/etc/fstab");
        assertThat(base.relativize(URL.parse("file:///etc/fstab"))).isEqualTo("");
        assertThat(base.relativize(URL.parse("file:///etc/fstab/bar"))).isEqualTo("bar");
        assertThat(base.relativize(URL.parse("file:///etc/fstab?bar#baz"))).isEqualTo("?bar#baz");

        base = URL.parse("file://localhost/etc/fstab");
        assertThat(base.relativize(URL.parse("file:///etc/fstab"))).isEqualTo("file:///etc/fstab");
    }

    @Test
    public void buildHierarchical() throws GalimatiasParseException {
        assertThat(URL.buildHierarchical("http", "example.com")).isEqualTo(URL.parse("http://example.com"));
        assertThat(URL.buildHierarchical("https", "example.com")).isEqualTo(URL.parse("https://example.com"));
        assertThat(URL.buildHierarchical("ftp", "example.com")).isEqualTo(URL.parse("ftp://example.com"));
    }

    @Test
    public void buildOpaque() throws GalimatiasParseException {
        assertThat(URL.buildOpaque("git")).isEqualTo(URL.parse("git:"));
        assertThat(URL.buildOpaque("ed2k")).isEqualTo(URL.parse("ed2k:"));
    }

    @Test
    public void buildFile() throws GalimatiasParseException {
        assertThat(URL.buildFile()).isEqualTo(URL.parse("file://"));
    }

    @Test(expected = GalimatiasParseException.class)
    public void buildHierarchicalWithOpaqueScheme() throws GalimatiasParseException {
        URL.buildHierarchical("git", "example.com");
    }

    @Test(expected = GalimatiasParseException.class)
    public void buildOpaqueWithHierarchical() throws GalimatiasParseException {
        URL.buildOpaque("http");
    }

    @Theory
    public void toHumanStringIdempotence(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG) TestURL testURL)
        throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        assumeTrue(testURL.parsedURL.host() instanceof Domain);
        Domain domain = (Domain) testURL.parsedURL.host();
        assertThat(domain.toHumanString()).isEqualTo(Domain.parseDomain(domain.toString()).toHumanString());
        assertThat(Domain.parseDomain(domain.toString(), true).toString()).isEqualTo(Domain.parseDomain(domain.toString()).toHumanString());
        assertThat(Domain.parseDomain(domain.toString(), true).toHumanString()).isEqualTo(Domain.parseDomain(domain.toString()).toHumanString());
    }

    @Test
    public void toHumanStringChecks() throws GalimatiasParseException {
        assertThat(URL.parse("http://á.com/").toHumanString()).isEqualTo("http://á.com/");
        assertThat(URL.parse("http://á.com/%2F").toHumanString()).isEqualTo("http://á.com//");
        assertThat(URL.parse("http://á.com/%7E?%2F#%2F").toHumanString()).isEqualTo("http://á.com/~?/#/");
        assertThat(URL.parse("http://á/").toHumanString()).isEqualTo("http://á/");
    }

    @Theory
    public void toHumanStringNoExceptions(final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG)
        TestURL testURL) throws GalimatiasParseException {
        assumeNotNull(testURL.parsedURL);
        testURL.parsedURL.toHumanString();
    }

}

redpajama_set_name: RedPajamaGithub


text:
// Generated on 2015-03-27 using generator-jekyllized 0.7.3
"use strict";

var gulp = require("gulp");
// Loads the plugins without having to list all of them, but you need
// to call them as $.pluginname
var $ = require("gulp-load-plugins")();
// "del" is used to clean out directories and such
var del = require("del");
// BrowserSync isn"t a gulp package, and needs to be loaded manually
var browserSync = require("browser-sync");
// merge is used to merge the output from two different streams into the same stream
var merge = require("merge-stream");
// Need a command for reloading webpages using BrowserSync
var reload = browserSync.reload;
// And define a variable that BrowserSync uses in it"s function
var bs;

// Deletes the directory that is used to serve the site during development
gulp.task("clean:dev", del.bind(null, ["serve"]));

// Deletes the directory that the optimized site is output to
gulp.task("clean:prod", del.bind(null, ["site"]));

// Runs the build command for Jekyll to compile the site locally
// This will build the site with the production settings
gulp.task("jekyll:dev", $.shell.task("jekyll build"));
gulp.task("jekyll-rebuild", ["jekyll:dev"], function () {
  reload;
});

// Almost identical to the above task, but instead we load in the build configuration
// that overwrites some of the settings in the regular configuration so that you
// don"t end up publishing your drafts or future posts
gulp.task("jekyll:prod", $.shell.task("jekyll build --config _config.yml,_config.build.yml"));

// Compiles the SASS files and moves them into the "assets/stylesheets" directory
gulp.task("styles", function () {
  // Looks at the style.scss file for what to include and creates a style.css file
  return gulp.src("src/assets/scss/style.scss")
    .pipe($.sass())
    // AutoPrefix your CSS so it works between browsers
    .pipe($.autoprefixer("last 1 version", { cascade: true }))
    // Directory your CSS file goes to
    .pipe(gulp.dest("src/assets/stylesheets/"))
    .pipe(gulp.dest("serve/assets/stylesheets/"))
    // Outputs the size of the CSS file
    .pipe($.size({title: "styles"}))
    // Injects the CSS changes to your browser since Jekyll doesn"t rebuild the CSS
    .pipe(reload({stream: true}));
});

// Optimizes the images that exists
gulp.task("images", function () {
  return gulp.src("src/assets/images/**")
    .pipe($.changed("site/assets/images"))
    .pipe($.imagemin({
      // Lossless conversion to progressive JPGs
      progressive: true,
      // Interlace GIFs for progressive rendering
      interlaced: true
    }))
    .pipe(gulp.dest("site/assets/images"))
    .pipe($.size({title: "images"}));
});

// Copy over fonts to the "site" directory
gulp.task("fonts", function () {
  return gulp.src("src/assets/fonts/**")
    .pipe(gulp.dest("site/assets/fonts"))
    .pipe($.size({ title: "fonts" }));
});

// Copy xml and txt files to the "site" directory
gulp.task("copy", function () {
  return gulp.src(["serve/*.txt", "serve/*.xml"])
    .pipe(gulp.dest("site"))
    .pipe($.size({ title: "xml & txt" }))
});

// Optimizes all the CSS, HTML and concats the JS etc
gulp.task("html", ["styles"], function () {
  var assets = $.useref.assets({searchPath: "serve"});

  return gulp.src("serve/**/*.html")
    .pipe(assets)
    // Concatenate JavaScript files and preserve important comments
    .pipe($.if("*.js", $.uglify({preserveComments: "some"})))
    // Minify CSS
    .pipe($.if("*.css", $.minifyCss()))
    // Start cache busting the files
    .pipe($.revAll({ ignore: [".eot", ".svg", ".ttf", ".woff"] }))
    .pipe(assets.restore())
    // Conctenate your files based on what you specified in _layout/header.html
    .pipe($.useref())
    // Replace the asset names with their cache busted names
    .pipe($.revReplace())
    // Minify HTML
    .pipe($.if("*.html", $.htmlmin({
      removeComments: true,
      removeCommentsFromCDATA: true,
      removeCDATASectionsFromCDATA: true,
      collapseWhitespace: true,
      collapseBooleanAttributes: true,
      removeAttributeQuotes: true,
      removeRedundantAttributes: true
    })))
    // Send the output to the correct folder
    .pipe(gulp.dest("site"))
    .pipe($.size({title: "optimizations"}));
});

// Run JS Lint against your JS
gulp.task("jslint", function () {
  gulp.src("./serve/assets/javascript/*.js")
    // Checks your JS code quality against your .jshintrc file
    .pipe($.jshint(".jshintrc"))
    .pipe($.jshint.reporter());
});

// Runs "jekyll doctor" on your site to check for errors with your configuration
// and will check for URL errors a well
gulp.task("doctor", $.shell.task("jekyll doctor"));

// BrowserSync will serve our site on a local server for us and other devices to use
// It will also autoreload across all devices as well as keep the viewport synchronized
// between them.
gulp.task("serve:dev", ["styles", "jekyll:dev"], function () {
  bs = browserSync({
    notify: true,
    // tunnel: "",
    server: {
      baseDir: "serve"
    }
  });
});

// These tasks will look for files that change while serving and will auto-regenerate or
// reload the website accordingly. Update or add other files you need to be watched.
gulp.task("watch", function () {
  gulp.watch(["src/**/*.md", "src/**/*.html", "src/**/*.xml", "src/**/*.txt", "src/**/*.js"], ["jekyll-rebuild"]);
  gulp.watch(["serve/assets/stylesheets/*.css"], reload);
  gulp.watch(["src/assets/scss/**/*.scss"], ["styles"]);
});

// Serve the site after optimizations to see that everything looks fine
gulp.task("serve:prod", function () {
  bs = browserSync({
    notify: false,
    // tunnel: true,
    server: {
      baseDir: "site"
    }
  });
});

// Default task, run when just writing "gulp" in the terminal
gulp.task("default", ["serve:dev", "watch"]);

// Checks your CSS, JS and Jekyll for errors
gulp.task("check", ["jslint", "doctor"], function () {
  // Better hope nothing is wrong.
});

// Builds the site but doesn"t serve it to you
gulp.task("build", ["jekyll:prod", "styles"], function () {});

// Builds your site with the "build" command and then runs all the optimizations on
// it and outputs it to "./site"
gulp.task("publish", ["build"], function () {
  gulp.start("html", "copy", "images", "fonts");
});


text: echo "UseDNS no" >> /etc/sshd_config


text:
package com.exalttech.trex.ui.controllers.ports;

import com.exalttech.trex.ui.controllers.ports.tabs.PortAttributes;
import com.exalttech.trex.ui.controllers.ports.tabs.PortHardwareCounters;
import com.exalttech.trex.ui.controllers.ports.tabs.PortLayerConfiguration;
import com.exalttech.trex.ui.models.PortModel;
import com.exalttech.trex.util.Initialization;
import javafx.beans.binding.Bindings;
import javafx.fxml.FXML;
import javafx.scene.control.TabPane;

public class PortView extends TabPane {

    @FXML
    private PortAttributes portAttributes;

    @FXML
    private PortLayerConfiguration layerConfig;

    @FXML
    PortHardwareCounters hardwareCounters;

    public PortView() {
        Initialization.initializeFXML(this, "/fxml/ports/Port.fxml");
        getSelectionModel().selectedItemProperty().addListener((observable, prevTab, currentTab) -> {
            if (currentTab.getId().equals("hardwareCountersTab")) {
                hardwareCounters.startPolling();
            } else {
                hardwareCounters.stopPolling();
            }
        });
        visibleProperty().addListener((observable, prevVisible, visible) -> {
            if (!visible) {
                hardwareCounters.stopPolling();
            }
        });
    }

    public void loadModel(PortModel model) {
        portAttributes.bindModel(model);
        layerConfig.bindModel(model);
        boolean runPolling = getSelectionModel().selectedItemProperty().get().getId().equals("hardwareCountersTab");
        hardwareCounters.bindModel(model, runPolling);

        layerConfig.disableProperty().unbind();
        layerConfig.setDisable(!model.isOwnedProperty().get());
        layerConfig.disableProperty().bind(Bindings.or(
            model.isOwnedProperty().not(),
            model.transmitStateProperty())
        );
    }

    public void stopPolling() {
        hardwareCounters.stopPolling();
    }
}


text:
#include "server.h"

#if defined(VGO_darwin)
// ???? darwin signal.h defines SIGPOLL conditionnally ????
#ifndef SIGPOLL
#define SIGPOLL 7
#endif
#endif

enum target_signal target_signal_from_name (const char *name);
enum target_signal target_signal_from_command (int num);

/* This table must match in order and size the signals in enum target_signal
   in gdb/signals.h. */
/* *INDENT-OFF* */
static struct {
   const char *name;
   const char *string;
} signals [] =
   {
      {"0", "Signal 0"},
      {"SIGHUP", "Hangup"},
      {"SIGINT", "Interrupt"},
      {"SIGQUIT", "Quit"},
      {"SIGILL", "Illegal instruction"},
      {"SIGTRAP", "Trace/breakpoint trap"},
      {"SIGABRT", "Aborted"},
      {"SIGEMT", "Emulation trap"},
      {"SIGFPE", "Arithmetic exception"},
      {"SIGKILL", "Killed"},
      {"SIGBUS", "Bus error"},
      {"SIGSEGV", "Segmentation fault"},
      {"SIGSYS", "Bad system call"},
      {"SIGPIPE", "Broken pipe"},
      {"SIGALRM", "Alarm clock"},
      {"SIGTERM", "Terminated"},
      {"SIGURG", "Urgent I/O condition"},
      {"SIGSTOP", "Stopped (signal)"},
      {"SIGTSTP", "Stopped (user)"},
      {"SIGCONT", "Continued"},
      {"SIGCHLD", "Child status changed"},
      {"SIGTTIN", "Stopped (tty input)"},
      {"SIGTTOU", "Stopped (tty output)"},
      {"SIGIO", "I/O possible"},
      {"SIGXCPU", "CPU time limit exceeded"},
      {"SIGXFSZ", "File size limit exceeded"},
      {"SIGVTALRM", "Virtual timer expired"},
      {"SIGPROF", "Profiling timer expired"},
      {"SIGWINCH", "Window size changed"},
      {"SIGLOST", "Resource lost"},
      {"SIGUSR1", "User defined signal 1"},
      {"SIGUSR2", "User defined signal 2"},
      {"SIGPWR", "Power fail/restart"},
      {"SIGPOLL", "Pollable event occurred"},
      {"SIGWIND", "SIGWIND"},
      {"SIGPHONE", "SIGPHONE"},
      {"SIGWAITING", "Process's LWPs are blocked"},
      {"SIGLWP", "Signal LWP"},
      {"SIGDANGER", "Swap space dangerously low"},
      {"SIGGRANT", "Monitor mode granted"},
      {"SIGRETRACT", "Need to relinquish monitor mode"},
      {"SIGMSG", "Monitor mode data available"},
      {"SIGSOUND", "Sound completed"},
      {"SIGSAK", "Secure attention"},
      {"SIGPRIO", "SIGPRIO"},
      {"SIG33", "Real-time event 33"},
      {"SIG34", "Real-time event 34"},
      {"SIG35", "Real-time event 35"},
      {"SIG36", "Real-time event 36"},
      {"SIG37", "Real-time event 37"},
      {"SIG38", "Real-time event 38"},
      {"SIG39", "Real-time event 39"},
      {"SIG40", "Real-time event 40"},
      {"SIG41", "Real-time event 41"},
      {"SIG42", "Real-time event 42"},
      {"SIG43", "Real-time event 43"},
      {"SIG44", "Real-time event 44"},
      {"SIG45", "Real-time event 45"},
      {"SIG46", "Real-time event 46"},
      {"SIG47", "Real-time event 47"},
      {"SIG48", "Real-time event 48"},
      {"SIG49", "Real-time event 49"},
      {"SIG50", "Real-time event 50"},
      {"SIG51", "Real-time event 51"},
      {"SIG52", "Real-time event 52"},
      {"SIG53", "Real-time event 53"},
      {"SIG54", "Real-time event 54"},
      {"SIG55", "Real-time event 55"},
      {"SIG56", "Real-time event 56"},
      {"SIG57", "Real-time event 57"},
      {"SIG58", "Real-time event 58"},
      {"SIG59", "Real-time event 59"},
      {"SIG60", "Real-time event 60"},
      {"SIG61", "Real-time event 61"},
      {"SIG62", "Real-time event 62"},
      {"SIG63", "Real-time event 63"},
      {"SIGCANCEL", "LWP internal signal"},
      {"SIG32", "Real-time event 32"},
      {"SIG64", "Real-time event 64"},
      {"SIG65", "Real-time event 65"},
      {"SIG66", "Real-time event 66"},
      {"SIG67", "Real-time event 67"},
      {"SIG68", "Real-time event 68"},
      {"SIG69", "Real-time event 69"},
      {"SIG70", "Real-time event 70"},
      {"SIG71", "Real-time event 71"},
      {"SIG72", "Real-time event 72"},
      {"SIG73", "Real-time event 73"},
      {"SIG74", "Real-time event 74"},
      {"SIG75", "Real-time event 75"},
      {"SIG76", "Real-time event 76"},
      {"SIG77", "Real-time event 77"},
      {"SIG78", "Real-time event 78"},
      {"SIG79", "Real-time event 79"},
      {"SIG80", "Real-time event 80"},
      {"SIG81", "Real-time event 81"},
      {"SIG82", "Real-time event 82"},
      {"SIG83", "Real-time event 83"},
      {"SIG84", "Real-time event 84"},
      {"SIG85", "Real-time event 85"},
      {"SIG86", "Real-time event 86"},
      {"SIG87", "Real-time event 87"},
      {"SIG88", "Real-time event 88"},
      {"SIG89", "Real-time event 89"},
      {"SIG90", "Real-time event 90"},
      {"SIG91", "Real-time event 91"},
      {"SIG92", "Real-time event 92"},
      {"SIG93", "Real-time event 93"},
      {"SIG94", "Real-time event 94"},
      {"SIG95", "Real-time event 95"},
      {"SIG96", "Real-time event 96"},
      {"SIG97", "Real-time event 97"},
      {"SIG98", "Real-time event 98"},
      {"SIG99", "Real-time event 99"},
      {"SIG100", "Real-time event 100"},
      {"SIG101", "Real-time event 101"},
      {"SIG102", "Real-time event 102"},
      {"SIG103", "Real-time event 103"},
      {"SIG104", "Real-time event 104"},
      {"SIG105", "Real-time event 105"},
      {"SIG106", "Real-time event 106"},
      {"SIG107", "Real-time event 107"},
      {"SIG108", "Real-time event 108"},
      {"SIG109", "Real-time event 109"},
      {"SIG110", "Real-time event 110"},
      {"SIG111", "Real-time event 111"},
      {"SIG112", "Real-time event 112"},
      {"SIG113", "Real-time event 113"},
      {"SIG114", "Real-time event 114"},
      {"SIG115", "Real-time event 115"},
      {"SIG116", "Real-time event 116"},
      {"SIG117", "Real-time event 117"},
      {"SIG118", "Real-time event 118"},
      {"SIG119", "Real-time event 119"},
      {"SIG120", "Real-time event 120"},
      {"SIG121", "Real-time event 121"},
      {"SIG122", "Real-time event 122"},
      {"SIG123", "Real-time event 123"},
      {"SIG124", "Real-time event 124"},
      {"SIG125", "Real-time event 125"},
      {"SIG126", "Real-time event 126"},
      {"SIG127", "Real-time event 127"},

      {"SIGINFO", "Information request"},

      {NULL, "Unknown signal"},
      {NULL, "Internal error: printing TARGET_SIGNAL_DEFAULT"},

      /* Mach exceptions */
      {"EXC_BAD_ACCESS", "Could not access memory"},
      {"EXC_BAD_INSTRUCTION", "Illegal instruction/operand"},
      {"EXC_ARITHMETIC", "Arithmetic exception"},
      {"EXC_EMULATION", "Emulation instruction"},
      {"EXC_SOFTWARE", "Software generated exception"},
      {"EXC_BREAKPOINT", "Breakpoint"},

      /* Last entry, used to check whether the table is the right size.  */
      {NULL, "TARGET_SIGNAL_MAGIC"}
   };
/* *INDENT-ON* */

/* Return the name for a signal.  */
const char *target_signal_to_name (enum target_signal sig)
{
   if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST)
       && signals[sig].name != NULL)
      return signals[sig].name;
   else
      /* I think the code which prints this will always print it along
         with the string, so no need to be verbose (very old comment).  */
      return "?";
}

/* Given a name, return its signal.  */
enum target_signal target_signal_from_name (const char *name)
{
   enum target_signal sig;

   /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
      for TARGET_SIGNAL_SIGCHLD.  SIGIOT, on the other hand, is more
      questionable; seems like by now people should call it SIGABRT
      instead.  */

   /* This ugly cast brought to you by the native VAX compiler.  */
   for (sig = TARGET_SIGNAL_HUP;
        sig < TARGET_SIGNAL_LAST;
        sig = (enum target_signal) ((int) sig + 1))
      if (signals[sig].name != NULL
          && strcmp (name, signals[sig].name) == 0)
         return sig;
   return TARGET_SIGNAL_UNKNOWN;
}

/* The following functions are to help certain targets deal
   with the signal/waitstatus stuff.  They could just as well be in
   a file called native-utils.c or unixwaitstatus-utils.c or whatever.  */

/* Convert host signal to our signals.  */
enum target_signal target_signal_from_host (int hostsig)
{
   /* A switch statement would make sense but would require special kludges
      to deal with the cases where more than one signal has the same number.  */

   if (hostsig == 0)
      return TARGET_SIGNAL_0;

#if defined (VKI_SIGHUP)
   if (hostsig == VKI_SIGHUP)
      return TARGET_SIGNAL_HUP;
#endif
#if defined (VKI_SIGINT)
   if (hostsig == VKI_SIGINT)
      return TARGET_SIGNAL_INT;
#endif
#if defined (VKI_SIGQUIT)
   if (hostsig == VKI_SIGQUIT)
      return TARGET_SIGNAL_QUIT;
#endif
#if defined (VKI_SIGILL)
   if (hostsig == VKI_SIGILL)
      return TARGET_SIGNAL_ILL;
#endif
#if defined (VKI_SIGTRAP)
   if (hostsig == VKI_SIGTRAP)
      return TARGET_SIGNAL_TRAP;
#endif
#if defined (VKI_SIGABRT)
   if (hostsig == VKI_SIGABRT)
      return TARGET_SIGNAL_ABRT;
#endif
#if defined (VKI_SIGEMT)
   if (hostsig == VKI_SIGEMT)
      return TARGET_SIGNAL_EMT;
#endif
#if defined (VKI_SIGFPE)
   if (hostsig == VKI_SIGFPE)
      return TARGET_SIGNAL_FPE;
#endif
#if defined (VKI_SIGKILL)
   if (hostsig == VKI_SIGKILL)
      return TARGET_SIGNAL_KILL;
#endif
#if defined (VKI_SIGBUS)
   if (hostsig == VKI_SIGBUS)
      return TARGET_SIGNAL_BUS;
#endif
#if defined (VKI_SIGSEGV)
   if (hostsig == VKI_SIGSEGV)
      return TARGET_SIGNAL_SEGV;
#endif
#if defined (VKI_SIGSYS)
   if (hostsig == VKI_SIGSYS)
      return TARGET_SIGNAL_SYS;
#endif
#if defined (VKI_SIGPIPE)
   if (hostsig == VKI_SIGPIPE)
      return TARGET_SIGNAL_PIPE;
#endif
#if defined (VKI_SIGALRM)
   if (hostsig == VKI_SIGALRM)
      return TARGET_SIGNAL_ALRM;
#endif
#if defined (VKI_SIGTERM)
   if (hostsig == VKI_SIGTERM)
      return TARGET_SIGNAL_TERM;
#endif
#if defined (VKI_SIGUSR1)
   if (hostsig == VKI_SIGUSR1)
      return TARGET_SIGNAL_USR1;
#endif
#if defined (VKI_SIGUSR2)
   if (hostsig == VKI_SIGUSR2)
      return TARGET_SIGNAL_USR2;
#endif
#if defined (VKI_SIGCLD)
   if (hostsig == VKI_SIGCLD)
      return TARGET_SIGNAL_CHLD;
#endif
#if defined (VKI_SIGCHLD)
   if (hostsig == VKI_SIGCHLD)
      return TARGET_SIGNAL_CHLD;
#endif
#if defined (VKI_SIGPWR)
   if (hostsig == VKI_SIGPWR)
      return TARGET_SIGNAL_PWR;
#endif
#if defined (VKI_SIGWINCH)
   if (hostsig == VKI_SIGWINCH)
      return TARGET_SIGNAL_WINCH;
#endif
#if defined (VKI_SIGURG)
   if (hostsig == VKI_SIGURG)
      return TARGET_SIGNAL_URG;
#endif
#if defined (VKI_SIGIO)
   if (hostsig == VKI_SIGIO)
      return TARGET_SIGNAL_IO;
#endif
#if defined (VKI_SIGPOLL)
   if (hostsig == VKI_SIGPOLL)
      return TARGET_SIGNAL_POLL;
#endif
#if defined (VKI_SIGSTOP)
   if (hostsig == VKI_SIGSTOP)
      return TARGET_SIGNAL_STOP;
#endif
#if defined (VKI_SIGTSTP)
   if (hostsig == VKI_SIGTSTP)
      return TARGET_SIGNAL_TSTP;
#endif
#if defined (VKI_SIGCONT)
   if (hostsig == VKI_SIGCONT)
      return TARGET_SIGNAL_CONT;
#endif
#if defined (VKI_SIGTTIN)
   if (hostsig == VKI_SIGTTIN)
      return TARGET_SIGNAL_TTIN;
#endif
#if defined (VKI_SIGTTOU)
   if (hostsig == VKI_SIGTTOU)
      return TARGET_SIGNAL_TTOU;
#endif
#if defined (VKI_SIGVTALRM)
   if (hostsig == VKI_SIGVTALRM)
      return TARGET_SIGNAL_VTALRM;
#endif
#if defined (VKI_SIGPROF)
   if (hostsig == VKI_SIGPROF)
      return TARGET_SIGNAL_PROF;
#endif
#if defined (VKI_SIGXCPU)
   if (hostsig == VKI_SIGXCPU)
      return TARGET_SIGNAL_XCPU;
#endif
#if defined (VKI_SIGXFSZ)
   if (hostsig == VKI_SIGXFSZ)
      return TARGET_SIGNAL_XFSZ;
#endif
#if defined (VKI_SIGWIND)
   if (hostsig == VKI_SIGWIND)
      return TARGET_SIGNAL_WIND;
#endif
#if defined (VKI_SIGPHONE)
   if (hostsig == VKI_SIGPHONE)
      return TARGET_SIGNAL_PHONE;
#endif
#if defined (VKI_SIGLOST)
   if (hostsig == VKI_SIGLOST)
      return TARGET_SIGNAL_LOST;
#endif
#if defined (VKI_SIGWAITING)
   if (hostsig == VKI_SIGWAITING)
      return TARGET_SIGNAL_WAITING;
#endif
#if defined (VKI_SIGCANCEL)
   if (hostsig == VKI_SIGCANCEL)
      return TARGET_SIGNAL_CANCEL;
#endif
#if defined (VKI_SIGLWP)
   if (hostsig == VKI_SIGLWP)
      return TARGET_SIGNAL_LWP;
#endif
#if defined (VKI_SIGDANGER)
   if (hostsig == VKI_SIGDANGER)
      return TARGET_SIGNAL_DANGER;
#endif
#if defined (VKI_SIGGRANT)
   if (hostsig == VKI_SIGGRANT)
      return TARGET_SIGNAL_GRANT;
#endif
#if defined (VKI_SIGRETRACT)
   if (hostsig == VKI_SIGRETRACT)
      return TARGET_SIGNAL_RETRACT;
#endif
#if defined (VKI_SIGMSG)
   if (hostsig == VKI_SIGMSG)
      return TARGET_SIGNAL_MSG;
#endif
#if defined (VKI_SIGSOUND)
   if (hostsig == VKI_SIGSOUND)
      return TARGET_SIGNAL_SOUND;
#endif
#if defined (VKI_SIGSAK)
   if (hostsig == VKI_SIGSAK)
      return TARGET_SIGNAL_SAK;
#endif
#if defined (VKI_SIGPRIO)
   if (hostsig == VKI_SIGPRIO)
      return TARGET_SIGNAL_PRIO;
#endif

   /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
   if (hostsig == _NSIG + EXC_BAD_ACCESS)
      return TARGET_EXC_BAD_ACCESS;
#endif
#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
   if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
      return TARGET_EXC_BAD_INSTRUCTION;
#endif
#if defined (EXC_ARITHMETIC) && defined (_NSIG)
   if (hostsig == _NSIG + EXC_ARITHMETIC)
      return TARGET_EXC_ARITHMETIC;
#endif
#if defined (EXC_EMULATION) && defined (_NSIG)
   if (hostsig == _NSIG + EXC_EMULATION)
      return TARGET_EXC_EMULATION;
#endif
#if defined (EXC_SOFTWARE) && defined (_NSIG)
   if (hostsig == _NSIG + EXC_SOFTWARE)
      return TARGET_EXC_SOFTWARE;
#endif
#if defined (EXC_BREAKPOINT) && defined (_NSIG)
   if (hostsig == _NSIG + EXC_BREAKPOINT)
      return TARGET_EXC_BREAKPOINT;
#endif

#if defined (VKI_SIGINFO)
   if (hostsig == VKI_SIGINFO)
      return TARGET_SIGNAL_INFO;
#endif

#if defined (VKI_SIGRTMIN)
   if (hostsig >= VKI_SIGRTMIN && hostsig < VKI_SIGRTMAX) {
      /* This block of TARGET_SIGNAL_REALTIME value is in order.  */
      if (33 <= hostsig && hostsig <= 63)
         return (enum target_signal)
            (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
      else if (hostsig == 32)
         return TARGET_SIGNAL_REALTIME_32;
      else if (64 <= hostsig && hostsig <= 127)
         return (enum target_signal)
            (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64);
   }
#endif

   error ("Valgrind GDBSERVER bug: (target_signal_from_host):"
          " unrecognized vki signal %d\n", hostsig);
   return TARGET_SIGNAL_UNKNOWN;
}

/* Convert a OURSIG (an enum target_signal) to the form used by the
   target operating system (refered to as the ``host'') or zero if the
   equivalent host signal is not available.  Set/clear OURSIG_OK
   accordingly. */

static
int do_target_signal_to_host (enum target_signal oursig,
                              int *oursig_ok)
{
   *oursig_ok = 1;
   switch (oursig) {
   case TARGET_SIGNAL_0:
      return 0;

#if defined (VKI_SIGHUP)
   case TARGET_SIGNAL_HUP:
      return VKI_SIGHUP;
#endif
#if defined (VKI_SIGINT)
   case TARGET_SIGNAL_INT:
      return VKI_SIGINT;
#endif
#if defined (VKI_SIGQUIT)
   case TARGET_SIGNAL_QUIT:
      return VKI_SIGQUIT;
#endif
#if defined (VKI_SIGILL)
   case TARGET_SIGNAL_ILL:
      return VKI_SIGILL;
#endif
#if defined (VKI_SIGTRAP)
   case TARGET_SIGNAL_TRAP:
      return VKI_SIGTRAP;
#endif
#if defined (VKI_SIGABRT)
   case TARGET_SIGNAL_ABRT:
      return VKI_SIGABRT;
#endif
#if defined (VKI_SIGEMT)
   case TARGET_SIGNAL_EMT:
      return VKI_SIGEMT;
#endif
#if defined (VKI_SIGFPE)
   case TARGET_SIGNAL_FPE:
      return VKI_SIGFPE;
#endif
#if defined (VKI_SIGKILL)
   case TARGET_SIGNAL_KILL:
      return VKI_SIGKILL;
#endif
#if defined (VKI_SIGBUS)
   case TARGET_SIGNAL_BUS:
      return VKI_SIGBUS;
#endif
#if defined (VKI_SIGSEGV)
   case TARGET_SIGNAL_SEGV:
      return VKI_SIGSEGV;
#endif
#if defined (VKI_SIGSYS)
   case TARGET_SIGNAL_SYS:
      return VKI_SIGSYS;
#endif
#if defined (VKI_SIGPIPE)
   case TARGET_SIGNAL_PIPE:
      return VKI_SIGPIPE;
#endif
#if defined (VKI_SIGALRM)
   case TARGET_SIGNAL_ALRM:
      return VKI_SIGALRM;
#endif
#if defined (VKI_SIGTERM)
   case TARGET_SIGNAL_TERM:
      return VKI_SIGTERM;
#endif
#if defined (VKI_SIGUSR1)
   case TARGET_SIGNAL_USR1:
      return VKI_SIGUSR1;
#endif
#if defined (VKI_SIGUSR2)
   case TARGET_SIGNAL_USR2:
      return VKI_SIGUSR2;
#endif
#if defined (VKI_SIGCHLD) || defined (VKI_SIGCLD)
   case TARGET_SIGNAL_CHLD:
#if defined (VKI_SIGCHLD)
      return VKI_SIGCHLD;
#else
      return VKI_SIGCLD;
#endif
#endif /* SIGCLD or SIGCHLD */
#if defined (VKI_SIGPWR)
   case TARGET_SIGNAL_PWR:
      return VKI_SIGPWR;
#endif
#if defined (VKI_SIGWINCH)
   case TARGET_SIGNAL_WINCH:
      return VKI_SIGWINCH;
#endif
#if defined (VKI_SIGURG)
   case TARGET_SIGNAL_URG:
      return VKI_SIGURG;
#endif
#if defined (VKI_SIGIO)
   case TARGET_SIGNAL_IO:
      return VKI_SIGIO;
#endif
#if defined (VKI_SIGPOLL)
   case TARGET_SIGNAL_POLL:
      return VKI_SIGPOLL;
#endif
#if defined (VKI_SIGSTOP)
   case TARGET_SIGNAL_STOP:
      return VKI_SIGSTOP;
#endif
#if defined (VKI_SIGTSTP)
   case TARGET_SIGNAL_TSTP:
      return VKI_SIGTSTP;
#endif
#if defined (VKI_SIGCONT)
   case TARGET_SIGNAL_CONT:
      return VKI_SIGCONT;
#endif
#if defined (VKI_SIGTTIN)
   case TARGET_SIGNAL_TTIN:
      return VKI_SIGTTIN;
#endif
#if defined (VKI_SIGTTOU)
   case TARGET_SIGNAL_TTOU:
      return VKI_SIGTTOU;
#endif
#if defined (VKI_SIGVTALRM)
   case TARGET_SIGNAL_VTALRM:
      return VKI_SIGVTALRM;
#endif
#if defined (VKI_SIGPROF)
   case TARGET_SIGNAL_PROF:
      return VKI_SIGPROF;
#endif
#if defined (VKI_SIGXCPU)
   case TARGET_SIGNAL_XCPU:
      return VKI_SIGXCPU;
#endif
#if defined (VKI_SIGXFSZ)
   case TARGET_SIGNAL_XFSZ:
      return VKI_SIGXFSZ;
#endif
#if defined (VKI_SIGWIND)
   case TARGET_SIGNAL_WIND:
      return VKI_SIGWIND;
#endif
#if defined (VKI_SIGPHONE)
   case TARGET_SIGNAL_PHONE:
      return VKI_SIGPHONE;
#endif
#if defined (VKI_SIGLOST)
   case TARGET_SIGNAL_LOST:
      return VKI_SIGLOST;
#endif
#if defined (VKI_SIGWAITING)
   case TARGET_SIGNAL_WAITING:
      return VKI_SIGWAITING;
#endif
#if defined (VKI_SIGCANCEL)
   case TARGET_SIGNAL_CANCEL:
      return VKI_SIGCANCEL;
#endif
#if defined (VKI_SIGLWP)
   case TARGET_SIGNAL_LWP:
      return VKI_SIGLWP;
#endif
#if defined (VKI_SIGDANGER)
   case TARGET_SIGNAL_DANGER:
      return VKI_SIGDANGER;
#endif
#if defined (VKI_SIGGRANT)
   case TARGET_SIGNAL_GRANT:
      return VKI_SIGGRANT;
#endif
#if defined (VKI_SIGRETRACT)
   case TARGET_SIGNAL_RETRACT:
      return VKI_SIGRETRACT;
#endif
#if defined (VKI_SIGMSG)
   case TARGET_SIGNAL_MSG:
      return VKI_SIGMSG;
#endif
#if defined (VKI_SIGSOUND)
   case TARGET_SIGNAL_SOUND:
      return VKI_SIGSOUND;
#endif
#if defined (VKI_SIGSAK)
   case TARGET_SIGNAL_SAK:
      return VKI_SIGSAK;
#endif
#if defined (VKI_SIGPRIO)
   case TARGET_SIGNAL_PRIO:
      return VKI_SIGPRIO;
#endif

      /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
   case TARGET_EXC_BAD_ACCESS:
      return _NSIG + EXC_BAD_ACCESS;
#endif
#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
   case TARGET_EXC_BAD_INSTRUCTION:
      return _NSIG + EXC_BAD_INSTRUCTION;
#endif
#if defined (EXC_ARITHMETIC) && defined (_NSIG)
   case TARGET_EXC_ARITHMETIC:
      return _NSIG + EXC_ARITHMETIC;
#endif
#if defined (EXC_EMULATION) && defined (_NSIG)
   case TARGET_EXC_EMULATION:
      return _NSIG + EXC_EMULATION;
#endif
#if defined (EXC_SOFTWARE) && defined (_NSIG)
   case TARGET_EXC_SOFTWARE:
      return _NSIG + EXC_SOFTWARE;
#endif
#if defined (EXC_BREAKPOINT) && defined (_NSIG)
   case TARGET_EXC_BREAKPOINT:
      return _NSIG + EXC_BREAKPOINT;
#endif

#if defined (VKI_SIGINFO)
   case TARGET_SIGNAL_INFO:
      return VKI_SIGINFO;
#endif

   default:
#if defined (VKI_SIGRTMIN)
      {
         int retsig = 0;

         if (oursig >= TARGET_SIGNAL_REALTIME_33
             && oursig <= TARGET_SIGNAL_REALTIME_63) {
            /* This block of signals is continuous, and
               TARGET_SIGNAL_REALTIME_33 is 33 by definition.  */
            retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
         } else if (oursig == TARGET_SIGNAL_REALTIME_32) {
            /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
               TARGET_SIGNAL_REALTIME_33.  It is 32 by definition.  */
            retsig = 32;
         } else if (oursig >= TARGET_SIGNAL_REALTIME_64
                    && oursig <= TARGET_SIGNAL_REALTIME_127) {
            /* This block of signals is continuous, and
               TARGET_SIGNAL_REALTIME_64 is 64 by definition.  */
            retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_64 + 64;
         }

         if (retsig >= VKI_SIGRTMIN && retsig < VKI_SIGRTMAX)
            return retsig;
      }
#endif
      error ("Valgrind GDBSERVER bug: (do_target_signal_to_host):"
             " unrecognized target signal %u\n", oursig);
      *oursig_ok = 0;
      return 0;
   }
}

int target_signal_to_host_p (enum target_signal oursig)
{
   int oursig_ok;
   do_target_signal_to_host (oursig, &oursig_ok);
   return oursig_ok;
}

int target_signal_to_host (enum target_signal oursig)
{
   int oursig_ok;
   int targ_signo = do_target_signal_to_host (oursig, &oursig_ok);
   if (!oursig_ok) {
      /* The user might be trying to do "signal SIGSAK" where this system
         doesn't have SIGSAK.  */
      warning ("Signal %s does not exist on this system.\n",
               target_signal_to_name (oursig));
      return 0;
   } else {
      return targ_signo;
   }
}

/* In some circumstances we allow a command to specify a numeric
   signal.  The idea is to keep these circumstances limited so that
   users (and scripts) develop portable habits.  For comparison,
   POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a
   numeric signal at all is obsolescent.  We are slightly more
   lenient and allow 1-15 which should match host signal numbers on
   most systems.  Use of symbolic signal names is strongly encouraged.  */

enum target_signal target_signal_from_command (int num)
{
   if (num >= 1 && num <= 15)
      return (enum target_signal) num;
   error ("Only signals 1-15 are valid as numeric signals.\n\
Use \"info signals\" for a list of symbolic signals.\n");
}


text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using HaloSharp.Extension;
using HaloSharp.Model.Halo5.Metadata;
using HaloSharp.Query.Halo5.Metadata;
using HaloSharp.Test.Config;
using HaloSharp.Test.Utility;
using Moq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Schema;
using NUnit.Framework;

namespace HaloSharp.Test.Query.Halo5.Metadata
{
    [TestFixture]
    public class GetSeasonsTests
    {
        private IHaloSession _mockSession;
        private List<Season> _seasons;

        [SetUp]
        public void Setup()
        {
            _seasons = JsonConvert.DeserializeObject<List<Season>>(File.ReadAllText(Halo5Config.SeasonsJsonPath));

            var mock = new Mock<IHaloSession>();
            mock.Setup(m => m.Get<List<Season>>(It.IsAny<string>()))
                .ReturnsAsync(_seasons);

            _mockSession = mock.Object;
        }

        [Test]
        public void Uri_MatchesExpected()
        {
            var query = new GetSeasons();

            Assert.AreEqual("https://www.haloapi.com/metadata/h5/metadata/seasons", query.Uri);
        }

        [Test]
        public async Task Query_DoesNotThrow()
        {
            var query = new GetSeasons()
                .SkipCache();

            var result = await _mockSession.Query(query);

            Assert.IsInstanceOf(typeof (List<Season>), result);
            Assert.AreEqual(_seasons, result);
        }

        [Test]
        public async Task GetSeasons_DoesNotThrow()
        {
            var query = new GetSeasons()
                .SkipCache();

            var result = await Global.Session.Query(query);

            Assert.IsInstanceOf(typeof(List<Season>), result);
        }

        [Test]
        public async Task GetSeasons_SchemaIsValid()
        {
            var seasonsSchema = JSchema.Parse(File.ReadAllText(Halo5Config.SeasonsJsonSchemaPath), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri = new Uri(Path.GetFullPath(Halo5Config.SeasonsJsonSchemaPath))
            });

            var query = new GetSeasons()
               .SkipCache();

            var jArray = await Global.Session.Get<JArray>(query.Uri);

            SchemaUtility.AssertSchemaIsValid(seasonsSchema, jArray);
        }

        [Test]
        public async Task GetSeasons_ModelMatchesSchema()
        {
            var schema = JSchema.Parse(File.ReadAllText(Halo5Config.SeasonsJsonSchemaPath), new JSchemaReaderSettings
            {
                Resolver = new JSchemaUrlResolver(),
                BaseUri = new Uri(Path.GetFullPath(Halo5Config.SeasonsJsonSchemaPath))
            });

            var query = new GetSeasons()
                .SkipCache();

            var result = await Global.Session.Query(query);

            var json = JsonConvert.SerializeObject(result);
            var jContainer = JsonConvert.DeserializeObject<JContainer>(json);

            SchemaUtility.AssertSchemaIsValid(schema, jContainer);
        }

        [Test]
        public async Task GetSeasons_IsSerializable()
        {
            var query = new GetSeasons()
               .SkipCache();

            var result = await Global.Session.Query(query);

            SerializationUtility<List<Season>>.AssertRoundTripSerializationIsPossible(result);
        }
    }
}


text:
package uk.co.CyniCode.CyniChat.Command;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import uk.co.CyniCode.CyniChat.Chatting.ServerChatListener;
import uk.co.CyniCode.CyniChat.CyniChat;
import uk.co.CyniCode.CyniChat.events.ChannelChatEvent;
import uk.co.CyniCode.CyniChat.objects.Channel;
import uk.co.CyniCode.CyniChat.objects.UserDetails;

/**
 * As much as this is playing with fire... this is for the /me command
 * so a player can write in the context of themselves
 * i.e. [g] Steve does this rather than [g] Steve : does that
 *
 * @author CyniCode
 */
public class MeCommand implements CommandExecutor {

	/**
	 * On the command...
	 * @param player : The player that is doing the command
	 * @param command : The command they're executing
	 * @param key : A keyword of sorts
	 * @param objects : All the arguments afterwards
	 * @return true when complete (as per interface)
	 */
	public boolean onCommand(CommandSender player, Command command, String key, String[] objects) {

		//Tell the console that shit is happening
		CyniChat.printDebug("Initialised a /me command");

		UserDetails thisUser = CyniChat.data.getOnlineDetails( (Player) player );
		Channel thisChan = CyniChat.data.getChannel( thisUser.getCurrentChannel() );

		if ( thisUser.getSilenced() ) {

			player.sendMessage( "You are silenced. You cannot speak." );
			return true;

		}

		if ( !thisUser.getAllChannels().contains( thisChan.getName() ) ) {

			player.sendMessage( "You are not in this channel." );
			return true;

		}

		if ( thisUser.getMutedChannels().contains( thisChan.getName() ) ) {

			player.sendMessage( "You are muted in this channel." );
			return true;

		}

		//And check to see if there is anything to put in the syntax of
		if ( objects[0] != null ) {

			//Now... create a message from the parts
			ChannelChatEvent newChat = new ChannelChatEvent(
					player.getName(),
					CyniChat.data.getChannel( CyniChat.data
						.getOnlineDetails( (Player) player )
						.getCurrentChannel() ),
					stacker( objects ),
					ServerChatListener.getRecipients(
						CyniChat.data.getOnlineDetails( (Player) player )
						.getCurrentChannel(), player.getName() ),
					""
				);

			Bukkit.getServer().getPluginManager().callEvent( newChat );

			//String linkedChan = CyniChat.data.getChannel(curChan).getIRC();

			//Tell the console that it's over
			CyniChat.printDebug("End of a /me command");
			return true;
		}

		//Or tell the player that they can't do this impossible acction
		player.sendMessage("Please provide an action to go with the /me command");
		return true;

	}

	/**
	 * Stack a message together into a sentence
	 * @param message : An array of words to be formed into a sentence
	 * @return the sentence produced from the words
	 */
	public String stacker( String[] message ) {

		//Initiailise the string
		String stackedMessage = "";

		//And for each object, add it to that string
		for (String message1 : message)
			stackedMessage +=  message1 + " ";

		//Then return the final string
		return stackedMessage;

	}

}