Search in sources :

Example 1 with EnvironmentType

use of br.com.caelum.vraptor.environment.EnvironmentType in project mamute by caelum.

the class AcceptanceTestBase method getEnv.

@BeforeClass
public static void getEnv() throws IOException {
    String homologEnv = System.getenv("ACCEPTANCE_ENV");
    if (homologEnv == null) {
        homologEnv = "development";
    }
    env = new DefaultEnvironment(new EnvironmentType(homologEnv));
}
Also used : DefaultEnvironment(br.com.caelum.vraptor.environment.DefaultEnvironment) EnvironmentType(br.com.caelum.vraptor.environment.EnvironmentType) BeforeClass(org.junit.BeforeClass)

Example 2 with EnvironmentType

use of br.com.caelum.vraptor.environment.EnvironmentType in project mamute by caelum.

the class ScriptSessionCreator method buildEnv.

private Environment buildEnv() {
    Environment env;
    try {
        String envName = System.getenv("DATAIMPORT_ENV");
        if (isNullOrEmpty(envName)) {
            envName = firstNonNull(System.getProperty(ENVIRONMENT_PROPERTY), "development");
        }
        env = new DefaultEnvironment(new EnvironmentType(envName));
        LOG.info("using env '" + envName + "' for script session creator");
        return env;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : DefaultEnvironment(br.com.caelum.vraptor.environment.DefaultEnvironment) EnvironmentType(br.com.caelum.vraptor.environment.EnvironmentType) DefaultEnvironment(br.com.caelum.vraptor.environment.DefaultEnvironment) Environment(br.com.caelum.vraptor.environment.Environment) IOException(java.io.IOException)

Example 3 with EnvironmentType

use of br.com.caelum.vraptor.environment.EnvironmentType in project mamute by caelum.

the class RssFeedFactoryTest method should_generate_feed.

@Test
public void should_generate_feed() throws IOException {
    DefaultEnvironment env = new DefaultEnvironment(new EnvironmentType("mamute"));
    QuestionRssEntryFactory factory = new QuestionRssEntryFactory(env);
    RssFeedFactory rssFeedFactory = new RssFeedFactory(env, factory);
    QuestionBuilder builder = new QuestionBuilder();
    DateTimeUtils.setCurrentMillisFixed(100);
    User user1 = user("author1", "author@email");
    user1.setPhotoUri(new URL("http://imagemsuser1.com"));
    Question question1 = builder.withAuthor(user1).withTitle("first question").withDescription("question").withId(1l).build();
    User user2 = user("author2", "author@email");
    user2.setPhotoUri(new URL("http://imagemsuser2.com"));
    Question question2 = builder.withId(2l).withTitle("second question").withAuthor(user2).build();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    rssFeedFactory.build(Arrays.<RssContent>asList(question1, question2), output, "title", "description");
    output.close();
    String xml = new String(output.toByteArray());
    assertTrue(xml.contains("first question"));
    assertTrue(xml.contains("second question"));
    assertTrue(xml.contains("http://imagemsuser1.com"));
    assertTrue(xml.contains("http://imagemsuser2.com"));
    DateTimeUtils.setCurrentMillisSystem();
}
Also used : DefaultEnvironment(br.com.caelum.vraptor.environment.DefaultEnvironment) EnvironmentType(br.com.caelum.vraptor.environment.EnvironmentType) User(org.mamute.model.User) RssFeedFactory(org.mamute.infra.rss.write.RssFeedFactory) QuestionBuilder(org.mamute.builder.QuestionBuilder) Question(org.mamute.model.Question) ByteArrayOutputStream(java.io.ByteArrayOutputStream) QuestionRssEntryFactory(org.mamute.infra.rss.write.QuestionRssEntryFactory) URL(java.net.URL) Test(org.junit.Test)

Example 4 with EnvironmentType

use of br.com.caelum.vraptor.environment.EnvironmentType in project mamute by caelum.

the class QuestionRssEntryFactoryTest method should_create_entry_from_a_question.

@Test
public void should_create_entry_from_a_question() throws IOException {
    DefaultEnvironment env = new DefaultEnvironment(new EnvironmentType("mamute"));
    QuestionRssEntryFactory factory = new QuestionRssEntryFactory(env);
    QuestionBuilder builder = new QuestionBuilder();
    DateTimeUtils.setCurrentMillisFixed(100);
    Question question = builder.withAuthor(user("author", "author@email")).withTitle("question title").withDescription("description").withId(1l).build();
    DateTimeUtils.setCurrentMillisSystem();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    factory.writeEntry(question, output);
    output.close();
    String xml = new String(output.toByteArray());
    assertTrue(xml.contains("<link>http://localhost:8080/1-question-title</link>"));
    assertTrue(xml.contains("<title><![CDATA[question title]]></title>"));
    assertTrue(xml.contains("<author><![CDATA[author]]></author>"));
}
Also used : DefaultEnvironment(br.com.caelum.vraptor.environment.DefaultEnvironment) EnvironmentType(br.com.caelum.vraptor.environment.EnvironmentType) QuestionBuilder(org.mamute.builder.QuestionBuilder) Question(org.mamute.model.Question) ByteArrayOutputStream(java.io.ByteArrayOutputStream) QuestionRssEntryFactory(org.mamute.infra.rss.write.QuestionRssEntryFactory) Test(org.junit.Test)

Aggregations

DefaultEnvironment (br.com.caelum.vraptor.environment.DefaultEnvironment)4 EnvironmentType (br.com.caelum.vraptor.environment.EnvironmentType)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Test (org.junit.Test)2 QuestionBuilder (org.mamute.builder.QuestionBuilder)2 QuestionRssEntryFactory (org.mamute.infra.rss.write.QuestionRssEntryFactory)2 Question (org.mamute.model.Question)2 Environment (br.com.caelum.vraptor.environment.Environment)1 IOException (java.io.IOException)1 URL (java.net.URL)1 BeforeClass (org.junit.BeforeClass)1 RssFeedFactory (org.mamute.infra.rss.write.RssFeedFactory)1 User (org.mamute.model.User)1