/testsuite/smoke/src/test/java/org/jboss/as/console/client/HostModelTest.java

https://github.com/kylape/console · Java · 138 lines · 73 code · 25 blank · 40 comment · 0 complexity · e5f83ef871aef945b20192f781178802 MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
  4. * as indicated by the @author tags. All rights reserved.
  5. * See the copyright.txt in the distribution for a
  6. * full listing of individual contributors.
  7. *
  8. * This copyrighted material is made available to anyone wishing to use,
  9. * modify, copy, or redistribute it subject to the terms and conditions
  10. * of the GNU Lesser General Public License, v. 2.1.
  11. * This program is distributed in the hope that it will be useful, but WITHOUT A
  12. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  13. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
  14. * You should have received a copy of the GNU Lesser General Public License,
  15. * v.2.1 along with this distribution; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. package org.jboss.as.console.client;
  20. /*
  21. * JBoss, Home of Professional Open Source
  22. * Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
  23. * as indicated by the @author tags. All rights reserved.
  24. * See the copyright.txt in the distribution for a
  25. * full listing of individual contributors.
  26. *
  27. * This copyrighted material is made available to anyone wishing to use,
  28. * modify, copy, or redistribute it subject to the terms and conditions
  29. * of the GNU Lesser General Public License, v. 2.1.
  30. * This program is distributed in the hope that it will be useful, but WITHOUT A
  31. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  32. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
  33. * You should have received a copy of the GNU Lesser General Public License,
  34. * v.2.1 along with this distribution; if not, write to the Free Software
  35. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  36. * MA 02110-1301, USA.
  37. */
  38. import com.google.inject.Guice;
  39. import com.google.inject.Injector;
  40. import org.jboss.as.console.client.domain.model.Host;
  41. import org.jboss.as.console.client.domain.model.HostInformationStore;
  42. import org.jboss.as.console.client.domain.model.Server;
  43. import org.jboss.as.console.client.domain.model.ServerInstance;
  44. import org.junit.BeforeClass;
  45. import org.junit.Test;
  46. import java.util.List;
  47. import static org.junit.Assert.assertEquals;
  48. import static org.junit.Assert.assertTrue;
  49. /**
  50. * @author Heiko Braun
  51. * @date 4/12/11
  52. */
  53. public class HostModelTest {
  54. private static Injector injector;
  55. @BeforeClass
  56. public static void init() {
  57. injector = Guice.createInjector(new TestModule());
  58. }
  59. @Test
  60. public void loadHosts() throws Exception
  61. {
  62. HostInformationStore store = injector.getInstance(HostInformationStore.class);
  63. TestCallback<List<Host>> callback = new TestCallback<List<Host>>() {
  64. @Override
  65. public void onSuccess(List<Host> result) {
  66. assertTrue("No hosts loaded", result.size()>0);
  67. assertEquals("master",result.get(0).getName());
  68. didCallback = true;
  69. }
  70. };
  71. store.getHosts(callback);
  72. synchronized (callback) {
  73. callback.wait(500);
  74. }
  75. assertTrue("Callback not executed", callback.hasBeenExecuted());
  76. }
  77. @Test
  78. public void loadServerConfigs() throws Exception
  79. {
  80. HostInformationStore store = injector.getInstance(HostInformationStore.class);
  81. TestCallback<List<Server>> callback = new TestCallback<List<Server>>() {
  82. @Override
  83. public void onSuccess(List<Server> result) {
  84. assertTrue("No server configurations loaded", result.size()>0);
  85. assertEquals("server-one",result.get(0).getName());
  86. didCallback = true;
  87. }
  88. };
  89. store.getServerConfigurations("master", callback);
  90. synchronized (callback) {
  91. callback.wait(500);
  92. }
  93. assertTrue("Callback not executed", callback.hasBeenExecuted());
  94. }
  95. @Test
  96. public void loadServerInstances() throws Exception
  97. {
  98. HostInformationStore store = injector.getInstance(HostInformationStore.class);
  99. TestCallback<List<ServerInstance>> callback = new TestCallback<List<ServerInstance>>() {
  100. @Override
  101. public void onSuccess(List<ServerInstance> result) {
  102. assertTrue("No servers instances loaded", result.size()>0);
  103. assertEquals("server-one",result.get(0).getName());
  104. didCallback = true;
  105. }
  106. };
  107. store.getServerInstances("master", callback);
  108. synchronized (callback) {
  109. callback.wait(500);
  110. }
  111. assertTrue("Callback not executed", callback.hasBeenExecuted());
  112. }
  113. }