public static Server startRestResourcesViaWebXml() throws Exception { return launcherWebXml().start(); }
public static Server startRestResourcesViaServlet() throws Exception { return launcherServlet().start(); }
/** due to the relative path search in {@link BrooklynRestApiLauncher} we can just call that method */ public static Server startJavascriptAndRest() throws Exception { return BrooklynRestApiLauncher.launcherServlet() .securityProvider(AnyoneSecurityProvider.class) .start(); }
protected Server newServer() { try { Server server = baseLauncher() .forceUseOfDefaultCatalogWithJavaClassPath(true) .start(); return server; } catch (Exception e) { throw Exceptions.propagate(e); } }
@BeforeClass public void setUp() throws Exception { server = BrooklynRestApiLauncher.launcher() .managementContext(manager) .securityProvider(TestSecurityProvider.class) .start(); api = BrooklynApi.newInstance("http://localhost:" + ((NetworkConnector)server.getConnectors()[0]).getPort() + "/v1", TestSecurityProvider.USER, TestSecurityProvider.PASSWORD); }
@BeforeClass(groups = "Integration") public void setUp() throws Exception { Server server = BrooklynRestApiLauncher.launcher() .managementContext(getManagementContext()) .start(); api = BrooklynApi.newInstance("http://localhost:" + ((NetworkConnector)server.getConnectors()[0]).getPort() + "/"); }
@Test(groups = "Integration") public void testGetUser() throws Exception { Server server = useServerForTest(baseLauncher() .securityProvider(TestSecurityProvider.class) .withoutJsgui() .start()); assertEquals(getServerUser(server), TestSecurityProvider.USER); }
@Test // doesn't work from IDE public void testWebAppStart() throws Exception { checkRestCatalogEntities(useServerForTest(baseLauncher().mode(WEB_XML).start())); }
@Test public void testServletStart() throws Exception { checkRestCatalogEntities(useServerForTest(baseLauncher().mode(SERVLET).start())); }
@Override @BeforeMethod(alwaysRun = true) public void setUp() throws Exception { super.setUp(); server = BrooklynRestApiLauncher.launcher().managementContext(mgmt).start(); client = HttpTool.httpClientBuilder().build(); String serverAddress = "http://localhost:"+((NetworkConnector)server.getConnectors()[0]).getLocalPort(); String appUrl = serverAddress + "/v1/applications/" + app.getId(); entityUrl = URI.create(appUrl + "/entities/" + app.getId()); configUri = new URIBuilder(entityUrl + "/config/" + TestEntity.CONF_OBJECT.getName()) .addParameter("raw", "true") .build(); }
).build(); apiLauncher.managementContext(mgmt); useServerForTest(apiLauncher.start()); HttpClient client = client();
@Test(groups = {"Integration","Broken"}) public void testInteractionOfSecurityFilterAndFormMapProvider() throws Exception { Stopwatch stopwatch = Stopwatch.createStarted(); try { Server server = useServerForTest(baseLauncher() .forceUseOfDefaultCatalogWithJavaClassPath(true) .withoutJsgui() .start()); String appId = startAppAtNode(server); String entityId = getTestEntityInApp(server, appId); HttpClient client = HttpTool.httpClientBuilder() .uri(getBaseUriRest()) .build(); List<? extends NameValuePair> nvps = Lists.newArrayList( new BasicNameValuePair("arg", "bar")); String effector = String.format("/applications/%s/entities/%s/effectors/identityEffector", appId, entityId); HttpToolResponse response = HttpTool.httpPost(client, URI.create(getBaseUriRest() + effector), ImmutableMap.of(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.getMimeType()), URLEncodedUtils.format(nvps, Charsets.UTF_8).getBytes()); LOG.info("Effector response: {}", response.getContentAsString()); assertTrue(HttpTool.isStatusCodeHealthy(response.getResponseCode()), "response code=" + response.getResponseCode()); } finally { LOG.info("testInteractionOfSecurityFilterAndFormMapProvider complete in " + Time.makeTimeStringRounded(stopwatch)); } }
useServerForTest(baseLauncher() .withoutJsgui() .start());
@BeforeMethod(alwaysRun=true) public void setUp() throws Exception { mgmt = LocalManagementContextForTests.builder(false).build(); app = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class) .child(EntitySpec.create(TestEntity.class))); entity = (TestEntity) Iterables.getOnlyElement(app.getChildren()); useServerForTest(baseLauncher() .managementContext(mgmt) .forceUseOfDefaultCatalogWithJavaClassPath(true) .start()); }
@BeforeMethod(alwaysRun=true) public void setUp() throws Exception { BrooklynProperties props = BrooklynProperties.Factory.newEmpty(); props.put(Entitlements.GLOBAL_ENTITLEMENT_MANAGER.getName(), PerUserEntitlementManager.class.getName()); props.put(PerUserEntitlementManager.PER_USER_ENTITLEMENTS_CONFIG_PREFIX+".myRoot", "root"); props.put(PerUserEntitlementManager.PER_USER_ENTITLEMENTS_CONFIG_PREFIX+".myReadonly", "readonly"); props.put(PerUserEntitlementManager.PER_USER_ENTITLEMENTS_CONFIG_PREFIX+".myMinimal", "minimal"); props.put(PerUserEntitlementManager.PER_USER_ENTITLEMENTS_CONFIG_PREFIX+".myUser", "user"); props.put(PerUserEntitlementManager.PER_USER_ENTITLEMENTS_CONFIG_PREFIX+".myCustom", StaticDelegatingEntitlementManager.class.getName()); props.put(BrooklynWebConfig.SECURITY_PROVIDER_CLASSNAME, AuthenticateAnyoneSecurityProvider.class.getName()); mgmt = LocalManagementContextForTests.builder(false).useProperties(props).build(); app = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class) .child(EntitySpec.create(TestEntity.class)) .configure(TestEntity.CONF_NAME, "myname")); entity = (TestEntity) Iterables.getOnlyElement(app.getChildren()); useServerForTest(baseLauncher() .managementContext(mgmt) .forceUseOfDefaultCatalogWithJavaClassPath(true) .start()); }
private void initHaCluster(HighAvailabilityMode writeMode, HighAvailabilityMode readMode) throws InterruptedException, TimeoutException { mementoDir = Os.newTempDir(getClass()); writeMgmt = createManagementContext(mementoDir, writeMode); appId = createApp(writeMgmt); writeMgmt.getRebindManager().waitForPendingComplete(TIMEOUT, true); if (readMode == HighAvailabilityMode.DISABLED) { //no HA, one node only readMgmt = writeMgmt; } else { readMgmt = createManagementContext(mementoDir, readMode); } server = useServerForTest(baseLauncher() .securityProvider(AnyoneSecurityProvider.class) .managementContext(readMgmt) .forceUseOfDefaultCatalogWithJavaClassPath(true) .withoutJsgui() .disableHighAvailability(false) .start()); client = getClient(server); }
private void setCorsFilterFeature(boolean enable, List<String> allowedOrigins) { if (enable) { BrooklynFeatureEnablement.enable(BrooklynFeatureEnablement.FEATURE_CORS_CXF_PROPERTY); } else { BrooklynFeatureEnablement.disable(BrooklynFeatureEnablement.FEATURE_CORS_CXF_PROPERTY); } BrooklynRestApiLauncher apiLauncher = baseLauncher() .withoutJsgui(); ManagementContext mgmt = LocalManagementContextForTests.builder(true) .useAdditionalProperties(MutableMap.<String, Object>of( BrooklynFeatureEnablement.FEATURE_CORS_CXF_PROPERTY, enable, BrooklynFeatureEnablement.FEATURE_CORS_CXF_PROPERTY + "." + CorsImplSupplierFilter.ALLOW_ORIGINS.getName(), allowedOrigins) ).build(); apiLauncher.managementContext(mgmt); useServerForTest(apiLauncher.start()); }
.withoutJsgui() .securityProvider(TestSecurityProvider.class) .start()); String baseUri = getBaseUriRest(server);