Skip to content

Commit f510341

Browse files
course content uploaded
1 parent a16b3d5 commit f510341

File tree

116 files changed

+11238
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+11238
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>edu.coursera.concurrent</groupId>
6+
<artifactId>miniproject_0</artifactId>
7+
<packaging>jar</packaging>
8+
<version>0.0</version>
9+
<name>miniproject_0</name>
10+
11+
<properties>
12+
<pcdp.version>0.0.4-SNAPSHOT</pcdp.version>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
</properties>
15+
16+
<repositories>
17+
<repository>
18+
<id>pcdp-repo</id>
19+
<url>https://raw.github.com/habanero-maven/hjlib-maven-repo/mvn-repo-pcdp-${pcdp.version}/</url>
20+
<snapshots>
21+
<enabled>true</enabled>
22+
<updatePolicy>always</updatePolicy>
23+
</snapshots>
24+
</repository>
25+
</repositories>
26+
27+
<dependencies>
28+
<dependency>
29+
<groupId>org.apache.maven.plugins</groupId>
30+
<artifactId>maven-resources-plugin</artifactId>
31+
<version>2.4.3</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>edu.rice.pcdp</groupId>
35+
<artifactId>pcdp-core</artifactId>
36+
<version>${pcdp.version}</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>junit</groupId>
40+
<artifactId>junit</artifactId>
41+
<version>3.8.2</version>
42+
<scope>test</scope>
43+
</dependency>
44+
</dependencies>
45+
46+
<build>
47+
<pluginManagement>
48+
<plugins>
49+
<plugin>
50+
<!-- specify the java version to use during compilation -->
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-compiler-plugin</artifactId>
53+
<version>3.1</version>
54+
<configuration>
55+
<source>1.8</source>
56+
<target>1.8</target>
57+
</configuration>
58+
</plugin>
59+
<plugin>
60+
<!-- populates the properties for dependency jar paths -->
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-dependency-plugin</artifactId>
63+
<version>2.9</version>
64+
<executions>
65+
<execution>
66+
<goals>
67+
<goal>properties</goal>
68+
</goals>
69+
</execution>
70+
</executions>
71+
</plugin>
72+
<plugin>
73+
<!-- executes test with -Xmx option -->
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-surefire-plugin</artifactId>
76+
<version>2.17</version>
77+
<configuration>
78+
<forkMode>pertest</forkMode>
79+
<argLine>-Xmx4g</argLine>
80+
<useSystemClassLoader>true</useSystemClassLoader>
81+
<testFailureIgnore>true</testFailureIgnore>
82+
</configuration>
83+
</plugin>
84+
<plugin>
85+
<groupId>org.apache.maven.plugins</groupId>
86+
<artifactId>maven-checkstyle-plugin</artifactId>
87+
<version>2.17</version>
88+
<executions>
89+
<execution>
90+
<id>checkstyle</id>
91+
<phase>validate</phase>
92+
<configuration>
93+
<configLocation>${basedir}/src/main/resources/checkstyle.xml</configLocation>
94+
<encoding>UTF-8</encoding>
95+
<consoleOutput>true</consoleOutput>
96+
<failsOnError>true</failsOnError>
97+
<failOnViolation>true</failOnViolation>
98+
</configuration>
99+
<goals>
100+
<goal>check</goal>
101+
</goals>
102+
</execution>
103+
</executions>
104+
</plugin>
105+
</plugins>
106+
</pluginManagement>
107+
</build>
108+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package edu.coursera.concurrent;
2+
3+
import static edu.rice.pcdp.PCDP.finish;
4+
import static edu.rice.pcdp.PCDP.async;
5+
6+
/**
7+
* A simple class for testing compilation of an PCDP project.
8+
*/
9+
public final class Setup {
10+
11+
/**
12+
* Default constructor.
13+
*/
14+
private Setup() {
15+
}
16+
17+
/**
18+
* A simple method for testing compilation of an PCDP project.
19+
* @param val Input value
20+
* @return Dummy value
21+
*/
22+
public static int setup(final int val) {
23+
final int[] result = new int[1];
24+
finish(() -> {
25+
async(() -> {
26+
result[0] = val;
27+
});
28+
});
29+
return result[0];
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Source code from the Java Concurrent Programming Coursera course.
3+
*/
4+
package edu.coursera.concurrent;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5+
6+
<!--
7+
Checkstyle configuration that checks the Google coding conventions from Google Java Style
8+
that can be found at https://google.github.io/styleguide/javaguide.html.
9+
Checkstyle is very configurable. Be sure to read the documentation at
10+
http://checkstyle.sf.net (or in your downloaded distribution).
11+
To completely disable a check, just comment it out or delete it from the file.
12+
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
13+
-->
14+
15+
<module name="Checker">
16+
<property name="charset" value="UTF-8"/>
17+
18+
<property name="severity" value="error"/>
19+
20+
<property name="fileExtensions" value="java, properties, xml"/>
21+
<!-- Checks for whitespace -->
22+
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
23+
<module name="FileTabCharacter">
24+
<property name="eachLine" value="true"/>
25+
</module>
26+
27+
<module name="TreeWalker">
28+
<module name="OuterTypeFilename"/>
29+
<module name="IllegalTokenText">
30+
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
31+
<property name="format"
32+
value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
33+
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
34+
</module>
35+
<module name="AvoidEscapedUnicodeCharacters">
36+
<property name="allowEscapesForControlCharacters" value="true"/>
37+
<property name="allowByTailComment" value="true"/>
38+
<property name="allowNonPrintableEscapes" value="true"/>
39+
</module>
40+
<!-- Google's answer here is 100, but for now we're just going to disable this (dwallach)
41+
<module name="LineLength">
42+
<property name="max" value="140"/>
43+
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
44+
</module> -->
45+
<!-- <module name="AvoidStarImport"/> this is actually useful in some cases (dwallach) -->
46+
<module name="OneTopLevelClass"/>
47+
<module name="NoLineWrap"/>
48+
<module name="EmptyBlock">
49+
<property name="option" value="TEXT"/>
50+
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
51+
</module>
52+
<module name="NeedBraces"/>
53+
<module name="LeftCurly">
54+
<property name="maxLineLength" value="100"/>
55+
</module>
56+
<module name="RightCurly"/>
57+
<module name="RightCurly">
58+
<property name="option" value="alone"/>
59+
<property name="tokens"
60+
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
61+
</module>
62+
<module name="WhitespaceAround">
63+
<property name="allowEmptyConstructors" value="true"/>
64+
<property name="allowEmptyMethods" value="true"/>
65+
<property name="allowEmptyTypes" value="true"/>
66+
<property name="allowEmptyLoops" value="true"/>
67+
<message key="ws.notFollowed"
68+
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
69+
<message key="ws.notPreceded"
70+
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
71+
</module>
72+
<module name="OneStatementPerLine"/>
73+
<module name="MultipleVariableDeclarations"/>
74+
<module name="ArrayTypeStyle"/>
75+
<module name="MissingSwitchDefault"/>
76+
<module name="FallThrough"/>
77+
<module name="UpperEll"/>
78+
<module name="ModifierOrder"/>
79+
<module name="EmptyLineSeparator">
80+
<property name="allowNoEmptyLineBetweenFields" value="true"/>
81+
</module>
82+
<module name="SeparatorWrap">
83+
<property name="tokens" value="DOT"/>
84+
<property name="option" value="nl"/>
85+
</module>
86+
<module name="SeparatorWrap">
87+
<property name="tokens" value="COMMA"/>
88+
<property name="option" value="EOL"/>
89+
</module>
90+
<module name="PackageName">
91+
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
92+
<message key="name.invalidPattern"
93+
value="Package name ''{0}'' must match pattern ''{1}''."/>
94+
</module>
95+
<module name="TypeName">
96+
<message key="name.invalidPattern"
97+
value="Type name ''{0}'' must match pattern ''{1}''."/>
98+
</module>
99+
<module name="MemberName">
100+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/> <!-- simplified (dwallach) -->
101+
<message key="name.invalidPattern"
102+
value="Member name ''{0}'' must match pattern ''{1}''."/>
103+
</module>
104+
<module name="ParameterName">
105+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/> <!-- simplified (dwallach) -->
106+
<message key="name.invalidPattern"
107+
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
108+
</module>
109+
<!-- <module name="CatchParameterName">
110+
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
111+
<message key="name.invalidPattern"
112+
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
113+
</module> -->
114+
<module name="LocalVariableName">
115+
<property name="tokens" value="VARIABLE_DEF"/>
116+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/> <!-- simplified (dwallach) -->
117+
<property name="allowOneCharVarInForLoop" value="true"/>
118+
<message key="name.invalidPattern"
119+
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
120+
</module>
121+
<module name="ClassTypeParameterName">
122+
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
123+
<message key="name.invalidPattern"
124+
value="Class type name ''{0}'' must match pattern ''{1}''."/>
125+
</module>
126+
<module name="MethodTypeParameterName">
127+
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
128+
<message key="name.invalidPattern"
129+
value="Method type name ''{0}'' must match pattern ''{1}''."/>
130+
</module>
131+
<module name="NoFinalizer"/>
132+
<module name="GenericWhitespace">
133+
<message key="ws.followed"
134+
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
135+
<message key="ws.preceded"
136+
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
137+
<message key="ws.illegalFollow"
138+
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
139+
<message key="ws.notPreceded"
140+
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
141+
</module>
142+
<module name="Indentation">
143+
<property name="basicOffset" value="4"/>
144+
<property name="braceAdjustment" value="0"/>
145+
<property name="caseIndent" value="4"/>
146+
<property name="throwsIndent" value="4"/>
147+
<property name="lineWrappingIndentation" value="4"/>
148+
<property name="arrayInitIndent" value="4"/>
149+
</module>
150+
<module name="AbbreviationAsWordInName">
151+
<property name="ignoreFinal" value="false"/>
152+
<property name="allowedAbbreviationLength" value="3"/> <!-- increased from 1 (dwallach) -->
153+
</module>
154+
<module name="OverloadMethodsDeclarationOrder"/>
155+
<module name="VariableDeclarationUsageDistance">
156+
<property name="allowedDistance" value="30"/> <!-- increased from 3 (dwallach) -->
157+
</module>
158+
<!-- too strict (dwallach)
159+
<module name="CustomImportOrder">
160+
<property name="specialImportsRegExp" value="com.google"/>
161+
<property name="sortImportsInGroupAlphabetically" value="true"/>
162+
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
163+
</module>
164+
-->
165+
<module name="MethodParamPad"/>
166+
<!-- too strict (dwallach)
167+
<module name="OperatorWrap">
168+
<property name="option" value="NL"/>
169+
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
170+
</module>
171+
-->
172+
<module name="AnnotationLocation">
173+
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
174+
</module>
175+
<module name="AnnotationLocation">
176+
<property name="tokens" value="VARIABLE_DEF"/>
177+
<property name="allowSamelineMultipleAnnotations" value="true"/>
178+
</module>
179+
<module name="NonEmptyAtclauseDescription"/>
180+
<module name="JavadocTagContinuationIndentation"/>
181+
<module name="SummaryJavadoc">
182+
<property name="forbiddenSummaryFragments"
183+
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
184+
</module>
185+
<module name="JavadocParagraph"/>
186+
<module name="AtclauseOrder">
187+
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
188+
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
189+
</module>
190+
<module name="JavadocMethod">
191+
<property name="scope" value="public"/>
192+
<property name="allowMissingParamTags" value="true"/>
193+
<property name="allowMissingThrowsTags" value="true"/>
194+
<property name="allowMissingReturnTag" value="true"/>
195+
<property name="minLineCount" value="2"/>
196+
<property name="allowedAnnotations" value="Override, Test"/>
197+
<property name="allowThrowsTagsForSubclasses" value="true"/>
198+
</module>
199+
<module name="MethodName">
200+
<property name="format" value="^[a-z][a-zA-Z0-9_]*$"/> <!-- simplified a bit (dwallach) -->
201+
<message key="name.invalidPattern"
202+
value="Method name ''{0}'' must match pattern ''{1}''."/>
203+
</module>
204+
<module name="SingleLineJavadoc">
205+
<property name="ignoreInlineTags" value="false"/>
206+
</module>
207+
<module name="EmptyCatchBlock">
208+
<property name="exceptionVariableName" value="expected"/>
209+
</module>
210+
<!-- <module name="CommentsIndentation"/> -->
211+
</module>
212+
</module>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package edu.coursera.concurrent;
2+
3+
import java.util.Random;
4+
5+
import junit.framework.TestCase;
6+
7+
public class SetupTest extends TestCase {
8+
9+
/*
10+
* A simple test case.
11+
*/
12+
public void testSetup() {
13+
final int result = Setup.setup(42);
14+
assertEquals(42, result);
15+
}
16+
}

0 commit comments

Comments
 (0)