コード例 #1
1
 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;
   }
 }
コード例 #2
0
 /** 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));
 }
コード例 #3
0
 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;
   }
 }
コード例 #4
0
 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));
 }
コード例 #5
0
ファイル: IsisMatchers.java プロジェクト: pugang/isis
  @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);
      }
    };
  }
コード例 #6
0
ファイル: IsisMatchers.java プロジェクト: pugang/isis
  @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);
      }
    };
  }
コード例 #7
0
ファイル: IsisMatchers.java プロジェクト: pugang/isis
  @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);
      }
    };
  }
コード例 #8
0
 /** 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));
 }
コード例 #9
0
  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;
  }
コード例 #11
0
 public boolean logonAsWithRoles(final String userName, final String roleListStr) {
   final List<String> roleList = StringUtils.splitOnCommas(StringUtils.normalized(roleListStr));
   getScenario().logonAsOrSwitchUserTo(userName, roleList);
   return true;
 }
コード例 #12
0
 public String checkCollectionSize(final String listAlias, final int size) {
   return new CheckCollectionContentsForConcordion(
           getScenario().getAliasRegistry(), StringUtils.normalized(listAlias))
       .assertSize(size);
 }
コード例 #13
0
 public String checkCollectionDoesNotContain(final String listAlias, final String alias) {
   return new CheckCollectionContentsForConcordion(
           getScenario().getAliasRegistry(), StringUtils.normalized(listAlias))
       .doesNotContain(StringUtils.normalized(alias));
 }
コード例 #14
0
 public String checkCollectionIsNotEmpty(final String listAlias) {
   return new CheckCollectionContentsForConcordion(
           getScenario().getAliasRegistry(), StringUtils.normalized(listAlias))
       .isNotEmpty();
 }
コード例 #15
0
 /**
  * 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;
 }
コード例 #16
0
 public boolean logonAs(final String userName) {
   getScenario().logonAsOrSwitchUserTo(StringUtils.normalized(userName));
   return true;
 }
コード例 #17
0
 /**
  * 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
 }
コード例 #18
0
 /**
  * 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);
 }