private void copyCustomCssIfDefined() { final Class<?> cssClass = customCssPackage(); final String customCss = customCss(); if (cssClass == null || customCss == null) { return; } final InputStream cssInputFile = cssClass.getResourceAsStream(customCss); final String cssPackageName = cssClass.getPackage().getName(); final String cssPackagePath = asPath(cssPackageName); final String cssOutputFileName = StringUtils.combinePaths(outputDir(), cssPackagePath, customCss); try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); IoUtils.copy(cssInputFile, baos); if (baos.size() > 0) { IoUtils.copy( new ByteArrayInputStream(baos.toByteArray()), new FileOutputStream(cssOutputFileName)); } } catch (final IllegalArgumentException e) { System.err.printf("failed to copy custom CSS to '%s'\n", customCss, cssOutputFileName); return; } catch (final IOException e) { System.err.printf("failed to copy custom CSS '%s' to '%s'\n", customCss, cssOutputFileName); return; } }
/** Workaround for OGNL defect. */ protected String setUpObjectsVarargs( final String className, final String alias, final String... propertyValues) { return setUpObjectsVarargsNormalized( StringUtils.normalized(className), StringUtils.normalized(alias), StringUtils.normalized(propertyValues)); }
public boolean aliasService(final String aliasAs, final String className) { try { getScenario() .getAliasRegistry() .aliasService(StringUtils.normalized(aliasAs), StringUtils.normalized(className)); return true; } catch (final ScenarioValueException e) { return false; } }
public String aliasItemsInList( final String listAlias, final String title, final String type, final String aliasAs) { aliasItemsInList = new AliasItemsInListForConcordion( getScenario().getAliasRegistry(), StringUtils.normalized(listAlias)); return aliasItemsInList.execute( StringUtils.normalized(aliasAs), StringUtils.normalized(title), StringUtils.normalized(type)); }
@Factory public static StringStartsWith startsWithStripNewLines(final String expected) { final String strippedExpected = StringUtils.stripNewLines(expected); return new StringStartsWith(strippedExpected) { @Override public boolean matchesSafely(final String actual) { return super.matchesSafely(StringUtils.stripNewLines(actual)); } @Override public void describeTo(final Description description) { description .appendText("a string (ignoring new lines) starting with") .appendValue(strippedExpected); } }; }
@Factory public static Matcher<String> containsStripNewLines(final String expected) { final String strippedExpected = StringUtils.stripNewLines(expected); return new StringContains(strippedExpected) { @Override public boolean matchesSafely(final String actual) { return super.matchesSafely(StringUtils.stripNewLines(actual)); } @Override public void describeTo(final Description description) { description .appendText("a string (ignoring new lines) containing") .appendValue(strippedExpected); } }; }
@Factory public static Matcher<String> equalToStripNewLines(final String expected) { final String strippedExpected = StringUtils.stripNewLines(expected); return new IsEqual<String>(strippedExpected) { @Override public boolean matches(final Object actualObj) { final String actual = (String) actualObj; return super.matches(StringUtils.stripNewLines(actual)); } @Override public void describeTo(final Description description) { description .appendText("a string (ignoring new lines) equal to") .appendValue(strippedExpected); } }; }
/** With <tt>protected</tt> visibility so that it can be called by custom methods if required. */ protected String usingIsisViewerThatArgsVarargs( final String onObject, final String aliasResultAs, final String perform, final String usingMember, final String thatIt, final String arg0, final String... remainingArgs) { return usingIsisViewerThatArgsVarargsNormalized( StringUtils.normalized(onObject), StringUtils.normalized(aliasResultAs), StringUtils.normalized(perform), StringUtils.normalized(usingMember), StringUtils.normalized(thatIt), StringUtils.normalized(arg0), StringUtils.normalized(remainingArgs)); }
public Iterable<Object> getListContents(final String listAlias) { final ObjectAdapter listAdapter = getScenario().getAliasRegistry().getAliased(StringUtils.normalized(listAlias)); if (listAdapter == null) { return Collections.emptyList(); } final CollectionFacet facet = listAdapter.getSpecification().getFacet(CollectionFacet.class); if (facet == null) { return Collections.emptyList(); } final Iterable<ObjectAdapter> objectAdapters = facet.iterable(listAdapter); return Iterables.transform( objectAdapters, new Function<ObjectAdapter, Object>() { @Override public Object apply(final ObjectAdapter from) { return from.getObject(); } }); }
@Override public void process(ProcessClassContext processClassContext) { final Class<?> cls = processClassContext.getCls(); final PersistenceCapable annotation = Annotations.getAnnotation(cls, PersistenceCapable.class); if (annotation == null) { return; } String annotationTableAttribute = annotation.table(); if (StringUtils.isNullOrEmpty(annotationTableAttribute)) { annotationTableAttribute = cls.getSimpleName(); } final IdentityType annotationIdentityType = annotation.identityType(); FacetUtil.addFacet( new JdoPersistenceCapableFacetAnnotation( annotationTableAttribute, annotationIdentityType, processClassContext.getFacetHolder())); return; }
public boolean logonAsWithRoles(final String userName, final String roleListStr) { final List<String> roleList = StringUtils.splitOnCommas(StringUtils.normalized(roleListStr)); getScenario().logonAsOrSwitchUserTo(userName, roleList); return true; }
public String checkCollectionSize(final String listAlias, final int size) { return new CheckCollectionContentsForConcordion( getScenario().getAliasRegistry(), StringUtils.normalized(listAlias)) .assertSize(size); }
public String checkCollectionDoesNotContain(final String listAlias, final String alias) { return new CheckCollectionContentsForConcordion( getScenario().getAliasRegistry(), StringUtils.normalized(listAlias)) .doesNotContain(StringUtils.normalized(alias)); }
public String checkCollectionIsNotEmpty(final String listAlias) { return new CheckCollectionContentsForConcordion( getScenario().getAliasRegistry(), StringUtils.normalized(listAlias)) .isNotEmpty(); }
/** * The directory to which the processed HTML should be copied. * * <p>Defaults to the value of the {@value #DEFAULT_CONCORDION_OUTPUT_DIR_PROPERTY} system * property, or {@value #DEFAULT_OUTPUT_DIR} if that property is not specified. * * <p>Can either be overridden if wish to specify some other mechanism for determining where the * output is generated. */ protected String outputDir() { final String concordionOutputDir = System.getProperty(DEFAULT_CONCORDION_OUTPUT_DIR_PROPERTY); return StringUtils.isNullOrEmpty(concordionOutputDir) ? DEFAULT_OUTPUT_DIR : concordionOutputDir; }
public boolean logonAs(final String userName) { getScenario().logonAsOrSwitchUserTo(StringUtils.normalized(userName)); return true; }
/** * For calling from XHTML script. * * @see #bootstrapIsis(String, DeploymentType) * @return <tt>boolean</tt> so that XHTML can assert on it. */ public boolean bootstrapIsis(final String configDirectory, final String deploymentTypeStr) { bootstrapIsis( configDirectory, DeploymentType.lookup(StringUtils.normalized(deploymentTypeStr))); return true; // any runtime exception will propagate }
/** * For calling within a <tt>#setUp()</tt> method. * * @see {@link #bootstrapIsis(String, String)} */ public void bootstrapIsis(final String configDirectory, final DeploymentType deploymentType) { getScenario().bootstrapIsis(StringUtils.normalized(configDirectory), deploymentType); }