@Test public void testGrammar() throws UnsupportedEncodingException { for (File swiftFile : swiftFiles) { ByteArrayOutputStream errContent = new ByteArrayOutputStream(); System.setErr(new PrintStream(errContent, false, Charset.defaultCharset().name())); String[] command = { "--debug", (TEST_INPUT_DIR + swiftFile.getName()) }; Tailor.main(command); assertThat(errContent.toString(Charset.defaultCharset().name()), IsEmptyString.isEmptyString()); System.setErr(null); } }
@Test public void runCodeSimple() throws Exception { ResultActions actions = this.mockMvc.perform(post("/jhawtcode/dynacode").param("code", "jhc.println(true);").param("replacementCP", fullClassPath)); //actions.andDo(print()); actions.andExpect(status().isOk()); //not the best content test, but works for now until gzip deflate actions.andExpect(content().string(new IsNot(new IsNull()))); actions.andExpect(content().string(new IsNot(new IsEmptyString()))); actions.andExpect(content().string(new IsEqualIgnoringWhiteSpace("true"))); }
@Test public void runCodeSimpleWithImport() throws Exception { ResultActions actions = this.mockMvc.perform(post("/jhawtcode/dynacode").param("code", "jhc.println(Math.pow(3,3));").param("replacementCP", fullClassPath).param("imports", "import java.lang.Math;")); //actions.andDo(print()); actions.andExpect(status().isOk()); //not the best content test, but works for now until gzip deflate actions.andExpect(content().string(new IsNot(new IsNull()))); actions.andExpect(content().string(new IsNot(new IsEmptyString()))); actions.andExpect(content().string(new IsEqualIgnoringWhiteSpace("27.0"))); }
@Test public void runCodeSimpleWithImportAndMethod() throws Exception { ResultActions actions = this.mockMvc.perform(post("/jhawtcode/dynacode").param("code", "jhc.println(Math.pow(3,addem(2,1)));").param("replacementCP", fullClassPath).param("imports", "import java.lang.Math;").param("methods", "public int addem(int a, int b) { return a+b; }")); //actions.andDo(print()); actions.andExpect(status().isOk()); //not the best content test, but works for now until gzip deflate actions.andExpect(content().string(new IsNot(new IsNull()))); actions.andExpect(content().string(new IsNot(new IsEmptyString()))); actions.andExpect(content().string(new IsEqualIgnoringWhiteSpace("27.0"))); }
@Test public void runCodeSimpleWithImportAndMethodAndGlobal() throws Exception { ResultActions actions = this.mockMvc.perform(post("/jhawtcode/dynacode").param("code", "jhc.println(Math.pow(3,addem(1,1)));").param("replacementCP", fullClassPath).param("imports", "import java.lang.Math;").param("methods", "public int addem(int a, int b) { return a+b+MYVAR; }").param("globals", "private int MYVAR=1;")); //actions.andDo(print()); actions.andExpect(status().isOk()); //not the best content test, but works for now until gzip deflate actions.andExpect(content().string(new IsNot(new IsNull()))); actions.andExpect(content().string(new IsNot(new IsEmptyString()))); actions.andExpect(content().string(new IsEqualIgnoringWhiteSpace("27.0"))); }
@Test public void getCSS() throws Exception { ResultActions actions = this.mockMvc.perform(get("/jhawtcode/jhc.css").accept(MediaType.TEXT_PLAIN)); //actions.andDo(print()); actions.andExpect(status().isOk()); // actions.andExpect(content().contentType(MediaType.TEXT_PLAIN)); //not the best content test, but works for now until gzip deflate actions.andExpect(content().string(new IsNot(new IsNull()))); actions.andExpect(content().string(new IsNot(new IsEmptyString()))); }
@Test public void getJS() throws Exception { ResultActions actions = this.mockMvc.perform(get("/jhawtcode/jhc.js").accept(MediaType.ALL)); //actions.andDo(print()); actions.andExpect(status().isOk()); // actions.andExpect(content().contentType(MediaType.)); //not the best content test, but works for now until gzip deflate actions.andExpect(content().string(new IsNot(new IsNull()))); actions.andExpect(content().string(new IsNot(new IsEmptyString()))); }
public void isEmpty() { verifyUsingMatcher(IsEmptyString.isEmptyString()); }
public void isNonEmpty() { verifyUsingMatcher(Matchers.not(IsEmptyString.isEmptyOrNullString())); }
public void isNullOrEmpty() { verifyUsingMatcher(IsEmptyString.isEmptyOrNullString()); }
public void notEmpty() { verifyUsingMatcher(Matchers.not(IsEmptyString.isEmptyOrNullString())); }
@Test public void versionStringShouldNotBeEmpty() { Assert.assertThat(Version.getCurrentVersion().toString(), new IsNot<>(new IsEmptyString())); }